ソースを参照

add cron feature

This commit adds all necessary configuration to execute cron jobs
inside the app
Tobias Brunner 8 年 前
コミット
37704e3bc2
3 ファイル変更25 行追加0 行削除
  1. 4 0
      Dockerfile
  2. 10 0
      index.php
  3. 11 0
      supervisor/cron.conf

+ 4 - 0
Dockerfile

@@ -38,6 +38,7 @@ RUN apt-get update && apt-get install -y php libapache2-mod-php crudini \
     php-yac \
     php-zip \
     proftpd proftpd-mod-ldap \
+    cron \
     && rm -rf /var/cache/apt /var/lib/apt/lists /etc/ssh_host_*
 
 # configure apache
@@ -71,6 +72,9 @@ 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

+ 10 - 0
index.php

@@ -84,6 +84,16 @@ sftp -P 2222 surfer.nebulon.info:public/
 
 <br/>
 
+<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.
+</p>
+<p>
+  Commands are executed as the user www-data.
+</p>
+
+<br/>
+
 <h2>Logs</h2>
 <p>Apache logs can be viewed using the <a href="https://cloudron.io/references/cli.html" target="_blank">cloudron commandline tool</a>.</p>
 <pre>

+ 11 - 0
supervisor/cron.conf

@@ -0,0 +1,11 @@
+[program:cron]
+directory=/
+command=/usr/sbin/cron -f -L 15
+user=root
+autostart=true
+autorestart=true
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+stderr_logfile=/dev/stderr
+stderr_logfile_maxbytes=0
+