Skip to content

Conversation

@mralexandernickel
Copy link

Because unless-stopped won't restart the container after the process
ended, we changed the restart policies for worker and cron to "always"
instead of "unless-stopped"

Also fix yaml syntax errors in docker-compose-pord.yml

Because unless-stopped won't restart the container after the process
ended, we changed the restart policies for worker and cron to "always"
instead of "unless-stopped"
x-restart-policy: &restart_policy
restart: unless-stopped

x-restart-policy-always: &restart_policy_always
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All containers must have the same restart policy. For example, after Docker daemon restarts, database is not started automatically, but worker is require a database

@vtsykun
Copy link
Owner

vtsykun commented Apr 25, 2023

Because unless-stopped won't restart the container after the process
ended.

But according to Docker docs: Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts.

I tested a cron worker with --time-limit=60 and see that process restarted always when exit with zero or any non zero error code.

More simple way to change restart policy is copy docker-compose.yml and change a one line

x-restart-policy: &restart_policy
    restart:  <policy>
cron_1      | + exec bin/console okvpn:cron --demand --time-limit=60
cron_1      | Run scheduler without exit
cron_1      | + [[ ! -z php-fpm:9000 ]]
cron_1      | + wait-for-it.sh php-fpm:9000
cron_1      | wait-for-it.sh: waiting 15 seconds for php-fpm:9000
cron_1      | wait-for-it.sh: php-fpm:9000 is available after 0 seconds
cron_1      | + [[ 1 == \1 ]]
cron_1      | + echo 'Skip init application'
cron_1      | + exec bin/console okvpn:cron --demand --time-limit=60
cron_1      | Skip init application
cron_1      | Run scheduler without exit
cron_1      | + [[ ! -z php-fpm:9000 ]]
cron_1      | + wait-for-it.sh php-fpm:9000
cron_1      | wait-for-it.sh: waiting 15 seconds for php-fpm:9000
cron_1      | wait-for-it.sh: php-fpm:9000 is available after 0 seconds
cron_1      | Skip init application
cron_1      | + [[ 1 == \1 ]]
cron_1      | + echo 'Skip init application'
cron_1      | + exec bin/console okvpn:cron --demand --time-limit=60
cron_1      | Run scheduler without exit
cron_1      | + [[ ! -z php-fpm:9000 ]]
cron_1      | + wait-for-it.sh php-fpm:9000
cron_1      | wait-for-it.sh: waiting 15 seconds for php-fpm:9000
cron_1      | wait-for-it.sh: php-fpm:9000 is available after 0 seconds
cron_1      | + [[ 1 == \1 ]]
cron_1      | + echo 'Skip init application'
cron_1      | Skip init application
cron_1      | + exec bin/console okvpn:cron --demand --time-limit=60
cron_1      | Run scheduler without exit
cron_1      | + [[ ! -z php-fpm:9000 ]]
cron_1      | + wait-for-it.sh php-fpm:9000
cron_1      | wait-for-it.sh: waiting 15 seconds for php-fpm:9000
cron_1      | wait-for-it.sh: php-fpm:9000 is available after 0 seconds
cron_1      | + [[ 1 == \1 ]]
cron_1      | + echo 'Skip init application'
cron_1      | + exec bin/console okvpn:cron --demand --time-limit=60
cron_1      | Skip init application
cron_1      | Run scheduler without exit
cron_1      | + [[ ! -z php-fpm:9000 ]]
cron_1      | + wait-for-it.sh php-fpm:9000
cron_1      | wait-for-it.sh: waiting 15 seconds for php-fpm:9000
cron_1      | wait-for-it.sh: php-fpm:9000 is available after 0 seconds
cron_1      | + [[ 1 == \1 ]]
cron_1      | + echo 'Skip init application'
cron_1      | + exec bin/console okvpn:cron --demand --time-limit=60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants