Explorar o código

make sure cronjobs get env variables

part of #11
Girish Ramakrishnan %!s(int64=7) %!d(string=hai) anos
pai
achega
a22ee91188
Modificáronse 2 ficheiros con 3 adicións e 3 borrados
  1. 1 1
      start.sh
  2. 2 2
      test/test.js

+ 1 - 1
start.sh

@@ -76,7 +76,7 @@ fi
 ## configure in-container Crontab
 if [ -f "/app/data/crontab" ]; then
     # http://www.gsp.com/cgi-bin/man.cgi?section=5&topic=crontab
-    if ! (cat /app/data/crontab; echo -e '\nMAILTO=""') | crontab -u www-data -; then
+    if ! (env; cat /app/data/crontab; echo -e '\nMAILTO=""') | crontab -u www-data -; then
         echo "Error importing crontab. Continuing anyway"
     else
         echo "Imported crontab"

+ 2 - 2
test/test.js

@@ -94,7 +94,7 @@ describe('Application life cycle test', function () {
     function checkCron(callback) {
         this.timeout(60000 * 2);
 
-        fs.writeFileSync('/tmp/crontab', '* * * * * echo -n "Cron task" > /app/data/public/cron\n', 'utf8');
+        fs.writeFileSync('/tmp/crontab', '* * * * * echo -n "$MYSQL_HOST" > /app/data/public/cron\n', 'utf8');
         execSync('cloudron push /tmp/crontab /app/data/crontab');
         fs.unlinkSync('/tmp/crontab');
 
@@ -108,7 +108,7 @@ describe('Application life cycle test', function () {
 
                 if (result.statusCode !== 200) return callback('Expecting 200, got ' + result.statusCode);
 
-                if (result.text !== 'Cron task') return callback('Unexpected text: ' + result.text);
+                if (result.text !== 'mysql') return callback('Unexpected text: ' + result.text);
 
                 callback();
             });