Bläddra i källkod

load crontab on app start

This changes the behaviour to not load the crontab automatically
but on the application startup. An app reload is needed to activate
an updated crontab.
Tobias Brunner 8 år sedan
förälder
incheckning
6e20caa062
3 ändrade filer med 7 tillägg och 5 borttagningar
  1. 0 3
      Dockerfile
  2. 2 2
      index.php
  3. 5 0
      start.sh

+ 0 - 3
Dockerfile

@@ -72,9 +72,6 @@ ADD proftpd.conf /app/code/proftpd.conf.template
 
 RUN rm -rf /var/log/proftpd && ln -s /run/proftpd /var/log/proftpd
 
-# configure cron
-RUN echo "* * * * * root test -f /app/data/crontab && ( crontab -u www-data /app/data/crontab )" > /etc/cron.d/lamp-app
-
 # configure supervisor
 ADD supervisor/ /etc/supervisor/conf.d/
 RUN sed -e 's,^logfile=.*$,logfile=/run/supervisord.log,' -i /etc/supervisor/supervisord.conf

+ 2 - 2
index.php

@@ -86,10 +86,10 @@ sftp -P 2222 surfer.nebulon.info:public/
 
 <h2>Cron</h2>
 <p>
-  Just put a file called crontab to the directory /app/data and it will picked up automatically. It has to be in the cron syntax without username.
+  Just put a file called crontab to the directory /app/data and it will picked up at next app restart. It has to be in the cron syntax without username.
 </p>
 <p>
-  Commands are executed as the user www-data.
+  Commands are executed as the user www-data. See <a href="https://linux.die.net/man/5/crontab">manpage</a> for a description of the file.
 </p>
 
 <br/>

+ 5 - 0
start.sh

@@ -70,6 +70,11 @@ if [ -f "/app/data/run.sh" ]; then
     /bin/bash /app/data/run.sh
 fi
 
+## configure in-container Crontab
+if [ -f "/app/data/crontab" ]; then
+  crontab -u www-data /app/data/crontab
+fi
+
 chown -R www-data:www-data /app/data /run/apache2 /run/proftpd /run/app
 
 echo "Starting supervisord"