From d2fda4af762ce0b127f15b0d1f62a7882e392a25 Mon Sep 17 00:00:00 2001 From: asus Date: Tue, 16 Apr 2024 16:42:29 +0200 Subject: [PATCH] added server cron handling in wordpress container --- .../wordpress/conf/wp_entrypoint.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/srcs/requirements/wordpress/conf/wp_entrypoint.sh b/srcs/requirements/wordpress/conf/wp_entrypoint.sh index b63d4b6..9fe8f10 100644 --- a/srcs/requirements/wordpress/conf/wp_entrypoint.sh +++ b/srcs/requirements/wordpress/conf/wp_entrypoint.sh @@ -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 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 & + +