From 454e9f55bb4e0aa501268430d5c88e3bff321e41 Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 27 Aug 2024 09:43:21 +0200 Subject: [PATCH 1/2] cron can sometimes fail when the database is not fully initialized, retries the cron job several times and catch catch the error on failure --- scripts/change_url | 7 ++++++- scripts/config | 7 ++++++- scripts/install | 7 ++++++- scripts/restore | 7 ++++++- scripts/upgrade | 7 ++++++- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index ff2770b..399a739 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -78,7 +78,12 @@ then systemctl enable --now ${app}-notify-push-watcher.path ynh_add_systemd_config --service="${app}-notify-push" - ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php + count=0 + while ! exec_occ background:cron && [[ $count -lt 30 ]] + do + sleep 1 + count=$((count + 1)) + done ynh_systemd_action --service_name="${app}-notify-push" --action=restart --line_match="Push daemon for Nextcloud clients." --log_path="systemd" --action=restart diff --git a/scripts/config b/scripts/config index 1a07d97..c3a06c6 100644 --- a/scripts/config +++ b/scripts/config @@ -141,7 +141,12 @@ set__enable_notify_push() { systemctl enable --now ${app}-notify-push-watcher.path ynh_add_systemd_config --service="${app}-notify-push" - exec_occ background:cron + count=0 + while ! exec_occ background:cron && [[ $count -lt 30 ]] + do + sleep 1 + count=$((count + 1)) + done ynh_systemd_action --service_name="${app}-notify-push-watcher" --action=restart ynh_systemd_action --service_name="${app}-notify-push" --action=restart --line_match="Push daemon for Nextcloud clients." --log_path="systemd" diff --git a/scripts/install b/scripts/install index a6f4d82..9b8698a 100755 --- a/scripts/install +++ b/scripts/install @@ -299,7 +299,12 @@ ynh_add_fail2ban_config --logpath="/var/log/$app/nextcloud.log" --failregex="^.* if [ $enable_notify_push -eq 1 ] then - ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php + count=0 + while ! exec_occ background:cron && [[ $count -lt 30 ]] + do + sleep 1 + count=$((count + 1)) + done ynh_systemd_action --service_name="${app}-notify-push-watcher" --action=restart ynh_systemd_action --service_name="${app}-notify-push" --action=restart --line_match="Push daemon for Nextcloud clients." --log_path="systemd" diff --git a/scripts/restore b/scripts/restore index 5607872..8bea858 100755 --- a/scripts/restore +++ b/scripts/restore @@ -162,7 +162,12 @@ exec_occ() { if [ $enable_notify_push -eq 1 ] then - ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php + count=0 + while ! exec_occ background:cron && [[ $count -lt 30 ]] + do + sleep 1 + count=$((count + 1)) + done ynh_systemd_action --service_name="${app}-notify-push-watcher" --action=restart ynh_systemd_action --service_name="${app}-notify-push" --action=restart --line_match="Push daemon for Nextcloud clients." --log_path="systemd" --action=restart diff --git a/scripts/upgrade b/scripts/upgrade index d3763e0..e34e20a 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -443,7 +443,12 @@ ynh_add_fail2ban_config --logpath="/var/log/$app/nextcloud.log" --failregex="^.* if [ $enable_notify_push -eq 1 ] then - ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php + count=0 + while ! exec_occ background:cron && [[ $count -lt 30 ]] + do + sleep 1 + count=$((count + 1)) + done ynh_systemd_action --service_name="${app}-notify-push-watcher" --action=restart ynh_systemd_action --service_name="${app}-notify-push" --action=restart --line_match="Push daemon for Nextcloud clients." --log_path="systemd" --action=restart From cbed1ef727602c5ff5a5dce57ecdee93720de202 Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 27 Aug 2024 11:48:44 +0200 Subject: [PATCH 2/2] oupsie --- scripts/change_url | 2 +- scripts/config | 2 +- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 399a739..326594f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -79,7 +79,7 @@ then ynh_add_systemd_config --service="${app}-notify-push" count=0 - while ! exec_occ background:cron && [[ $count -lt 30 ]] + while ! ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php && [[ $count -lt 30 ]] do sleep 1 count=$((count + 1)) diff --git a/scripts/config b/scripts/config index c3a06c6..189c448 100644 --- a/scripts/config +++ b/scripts/config @@ -142,7 +142,7 @@ set__enable_notify_push() { ynh_add_systemd_config --service="${app}-notify-push" count=0 - while ! exec_occ background:cron && [[ $count -lt 30 ]] + while ! ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php && [[ $count -lt 30 ]] do sleep 1 count=$((count + 1)) diff --git a/scripts/install b/scripts/install index 9b8698a..2df768a 100755 --- a/scripts/install +++ b/scripts/install @@ -300,7 +300,7 @@ ynh_add_fail2ban_config --logpath="/var/log/$app/nextcloud.log" --failregex="^.* if [ $enable_notify_push -eq 1 ] then count=0 - while ! exec_occ background:cron && [[ $count -lt 30 ]] + while ! ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php && [[ $count -lt 30 ]] do sleep 1 count=$((count + 1)) diff --git a/scripts/restore b/scripts/restore index 8bea858..1393ae3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -163,7 +163,7 @@ exec_occ() { if [ $enable_notify_push -eq 1 ] then count=0 - while ! exec_occ background:cron && [[ $count -lt 30 ]] + while ! ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php && [[ $count -lt 30 ]] do sleep 1 count=$((count + 1)) diff --git a/scripts/upgrade b/scripts/upgrade index e34e20a..7706d05 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -444,7 +444,7 @@ ynh_add_fail2ban_config --logpath="/var/log/$app/nextcloud.log" --failregex="^.* if [ $enable_notify_push -eq 1 ] then count=0 - while ! exec_occ background:cron && [[ $count -lt 30 ]] + while ! ynh_exec_as "$app" php${phpversion} --define apc.enable_cli=1 $install_dir/cron.php && [[ $count -lt 30 ]] do sleep 1 count=$((count + 1))