added server cron handling in wordpress container

This commit is contained in:
asus
2024-04-16 16:42:29 +02:00
parent ce6d6b442a
commit d2fda4af76

View File

@@ -12,7 +12,6 @@ RESET="\e[0m"
# it gets the ENV variables from .env because specified in the docker-compose.yml file
# this is to make the wp_cron job works
# ! it might not be a very strong solution
#
@@ -77,7 +76,7 @@ else
fi
# installing plugins :
echo -e ${YELLOW}installing plugins...${RESET}
echo -e ${YELLOW}installing plugins..${RESET}
plugins=$(ls ${WP_VOLUME_PLUGINS})
echo $plugins
for dir in $plugins; do
@@ -96,6 +95,20 @@ php wp-cli.phar config set WP_DEBUG_LOG true --raw --path=${WP_VOLUME_DIR}
php wp-cli.phar config set WP_DEBUG_DISPLAY false --raw --path=${WP_VOLUME_DIR}
# if you don't want to rely on wpcron :
# - because it launches on each visit of the website
# - so it can slow it
# - instead creates a real cron job to call the wpcron file regularly
# launch the server cron job, and disable wpcron
# in the container, the crond deamon is started manually, so it is listed with :
# - ps aux
# - kill <PID> to remove it for example
# -> https://stackoverflow.com/questions/37015624/how-to-run-a-cron-job-inside-a-docker-container
php wp-cli.phar config set DISABLE_WP_CRON false --raw --path=${WP_VOLUME_DIR}
echo "* * * * * cd ${WP_VOLUME_DIR}; php ${WP_VOLUME_DIR}/wp-cron.php > /dev/null 2>&1" >> /etc/crontabs/root
crond -f -l 2 >> /var/log/wpcron.log 2>&1 &