From 38842cdb4f53b8ea1a357395585a89fc11986c59 Mon Sep 17 00:00:00 2001 From: Todor Ivanov Date: Mon, 17 Jun 2024 17:01:46 +0300 Subject: [PATCH] Start cron daemon with root externally upon docker run (#1506) * Start cron daemon with root externally upon docker run Switch from /etc/init.d/cron to service command * Preserve the env for the cron daemon && Add --only-cron for wmagent-couchapp-init && Add timestamps --- docker/pypi/wmagent/Dockerfile | 3 +++ docker/pypi/wmagent/init.sh | 5 +++-- docker/pypi/wmagent/wmagent-docker-run.sh | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docker/pypi/wmagent/Dockerfile b/docker/pypi/wmagent/Dockerfile index ea543ab9e..01a3cbf89 100644 --- a/docker/pypi/wmagent/Dockerfile +++ b/docker/pypi/wmagent/Dockerfile @@ -62,5 +62,8 @@ EOF # allow dynamic users to create homefolders and .bashrc RUN chmod 777 /home +# preserve the whole env for later use by the cron daemon +RUN env > /etc/environment + # Define the entrypoint (Using exec form): ENTRYPOINT ["./run.sh", "2>&1"] diff --git a/docker/pypi/wmagent/init.sh b/docker/pypi/wmagent/init.sh index 0a189fc66..6621baa78 100755 --- a/docker/pypi/wmagent/init.sh +++ b/docker/pypi/wmagent/init.sh @@ -59,6 +59,7 @@ echo " - WMAgent Number : $AGENT_NUMBER" echo " - WMAgent Relational DB type : $AGENT_FLAVOR" echo " - Python Version : $(python --version)" echo " - Python Module path : $pythonLib" +echo " - Current time : $(date -Im)" echo "=======================================================" echo @@ -324,14 +325,14 @@ set_cronjob() { # Populating proxy related cronjobs crontab -u $WMA_USER - <> $WMA_LOG_DIR/renew-proxy.log && $WMA_MANAGE_DIR/manage renew-proxy 2>&1 >> $WMA_LOG_DIR/renew-proxy.log 58 */12 * * * python $WMA_DEPLOY_DIR/deploy/checkProxy.py --proxy /data/certs/myproxy.pem --time 120 --send-mail True --mail alan.malta@cern.ch */15 * * * * source $WMA_DEPLOY_DIR/deploy/restartComponent.sh > /dev/null EOF let errVal+=$? # Populating CouchDB related cronjobs - wmagent-couchapp-init + wmagent-couchapp-init --only-cron let errVal+=$? [[ $errVal -eq 0 ]] || { diff --git a/docker/pypi/wmagent/wmagent-docker-run.sh b/docker/pypi/wmagent/wmagent-docker-run.sh index eb1d11cc8..cff662ee0 100755 --- a/docker/pypi/wmagent/wmagent-docker-run.sh +++ b/docker/pypi/wmagent/wmagent-docker-run.sh @@ -132,3 +132,4 @@ echo "Checking if there is no other wmagent container running and creating a lin echo "Starting wmagent:$WMA_TAG docker container with user: $wmaUser:$wmaGroup" docker run $dockerOpts $registry/$repository:$WMA_TAG +docker exec -u root -it wmagent service cron start