Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions crontab/crontab
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
@hourly export $(cat /var/www/docker.env) && /bin/sh /var/www/eramba/app/upgrade/bin/cake cron job hourly >> /var/log/cron.log 2>&1
@daily export $(cat /var/www/docker.env) && /bin/sh /var/www/eramba/app/upgrade/bin/cake cron job daily >> /var/log/cron.log 2>&1
@yearly export $(cat /var/www/docker.env) && /bin/sh /var/www/eramba/app/upgrade/bin/cake cron job yearly >> /var/log/cron.log 2>&1
* * * * * export $(cat /var/www/docker.env) && /bin/sh /var/www/eramba/app/upgrade/bin/cake queue run -v >> /var/log/cron.log 2>&1
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

@hourly su -s /bin/bash -c "/var/www/eramba/app/upgrade/bin/cake cron job hourly" www-data >/proc/1/fd/1 2>/proc/1/fd/2
@daily su -s /bin/bash -c "/var/www/eramba/app/upgrade/bin/cake cron job daily" www-data >/proc/1/fd/1 2>/proc/1/fd/2
@yearly su -s /bin/bash -c "/var/www/eramba/app/upgrade/bin/cake cron job yearly" www-data >/proc/1/fd/1 2>/proc/1/fd/2
* * * * * su -s /bin/bash -c "/var/www/eramba/app/upgrade/bin/cake queue run -v" www-data >/proc/1/fd/1 2>/proc/1/fd/2

# remember to end this file with an empty new line
5 changes: 2 additions & 3 deletions docker-compose.simple-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
- ./apache/ssl/mycert.key:/etc/ssl/private/mycert.key
- ./apache/security.conf:/etc/apache2/conf-available/security.conf
- ./apache/vhost-ssl.conf:/etc/apache2/sites-available/000-default.conf
- ./crontab/crontab:/etc/cron.d/eramba-crontab
- ./docker-entrypoint.sh:/docker-entrypoint.sh
environment:
DB_HOST: ${DB_HOST}
DB_DATABASE: ${DB_DATABASE}
Expand All @@ -56,7 +56,7 @@ services:
cron:
container_name: cron
image: ghcr.io/eramba/eramba:latest
command: ["cron", "-f"]
command: ["cron", "-f", "-L", "2"]
entrypoint: ["/docker-cron-entrypoint.sh"]
restart: always
volumes:
Expand All @@ -65,7 +65,6 @@ services:
- logs:/var/www/eramba/app/upgrade/logs
- ./docker-cron-entrypoint.sh:/docker-cron-entrypoint.sh
- ./crontab/crontab:/etc/cron.d/eramba-crontab
- .env:/var/www/docker.env
environment:
DB_HOST: ${DB_HOST}
DB_DATABASE: ${DB_DATABASE}
Expand Down
14 changes: 12 additions & 2 deletions docker-cron-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/sh

su -s /bin/bash -c "crontab -u www-data /etc/cron.d/eramba-crontab" www-data
env >> /etc/environment

exec docker-php-entrypoint "$@"
crontab -u www-data -r
crontab -u root /etc/cron.d/eramba-crontab

# Run Post Install CMD to generate app_local.php file with unique SALT and other defaults.
su -s /bin/bash -c "php /var/www/eramba/composer.phar run-script post-install-cmd --working-dir=/var/www/eramba --no-interaction" www-data

su -s /bin/bash -c "php /var/www/eramba/app/upgrade/bin/cake.php queue worker end all" www-data

# execute CMD
echo "$@"
exec "$@"
5 changes: 4 additions & 1 deletion docker-entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ su -s /bin/bash -c "php composer.phar run-script post-install-cmd --no-interacti
# syncing dir structure into /data folder from /data_template
su -s /bin/bash -c "rsync -rv app/upgrade/data_template/ app/upgrade/data/" www-data

# syncing dir structure into /logs folder from /logs_template
su -s /bin/bash -c "rsync -rv app/upgrade/logs_template/ app/upgrade/logs/" www-data

# when deploying a code or DB migration change and you want the "old workers" based on the old code
# to not process any new incoming jobs after deployment.
su -s /bin/bash -c "php app/upgrade/bin/cake.php queue worker end all -q" www-data
#su -s /bin/bash -c "php app/upgrade/bin/cake.php queue worker end all -q" www-data

# Lets activate maintenance mode
#su -s /bin/bash -c "php app/upgrade/bin/cake.php setup.maintenance_mode activate" www-data
Expand Down