mirror of
https://github.com/YunoHost-Apps/snserver_ynh.git
synced 2024-09-03 20:26:22 +02:00
Fix: Check if service is ready
This commit is contained in:
parent
22948cdea0
commit
8b25b3f96a
7 changed files with 57 additions and 4 deletions
|
@ -39,6 +39,19 @@ exec_as() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Check if service is ready
|
||||
is_service_ready() {
|
||||
for ((i = 0 ; i < 15 ; i++))
|
||||
do
|
||||
if [ "200" -eq $(curl --silent --insecure --resolve $domain:443:127.0.0.1 https://$domain$path_url/ -o /dev/null --write-out "%{http_code}") ]
|
||||
then
|
||||
break
|
||||
else
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -87,6 +88,13 @@ ynh_script_progression --message="Restarting $app ..."
|
|||
|
||||
ynh_systemd_action --service_name=$app --action=restart
|
||||
|
||||
#=================================================
|
||||
# WAITING FOR SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Waiting for service..." --weight=1
|
||||
|
||||
is_service_ready
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -83,6 +84,13 @@ ynh_script_progression --message="Restarting $app ..."
|
|||
|
||||
ynh_systemd_action --service_name=$app --action=restart
|
||||
|
||||
#=================================================
|
||||
# WAITING FOR SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Waiting for service..." --weight=1
|
||||
|
||||
is_service_ready
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -161,7 +161,6 @@ ynh_add_fail2ban_config --use_template --others_var="\
|
|||
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
curl --silent --insecure --resolve $domain:443:127.0.0.1 https://$domain$path_url/ -o /dev/null --write-out "%{http_code}" --retry 10 --retry-delay 3
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
|
@ -170,6 +169,13 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
|||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# WAITING FOR SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Waiting for service..." --weight=1
|
||||
|
||||
is_service_ready
|
||||
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
|
|
|
@ -277,7 +277,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
curl --silent --insecure --resolve $domain:443:127.0.0.1 https://$domain$path_url/ -o /dev/null --write-out "%{http_code}" --retry 10 --retry-delay 3
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
|
@ -286,6 +285,13 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
|||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# WAITING FOR SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Waiting for service..." --weight=1
|
||||
|
||||
is_service_ready
|
||||
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
|
|
|
@ -131,7 +131,6 @@ yunohost service add $app --description "Standard Notes - Syncing Server" --log
|
|||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
curl --silent --insecure --resolve $domain:443:127.0.0.1 https://$domain$path_url/ -o /dev/null --write-out "%{http_code}" --retry 10 --retry-delay 3
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
|
@ -159,6 +158,13 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=2
|
|||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# WAITING FOR SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Waiting for service..." --weight=1
|
||||
|
||||
is_service_ready
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -318,7 +318,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
curl --silent --insecure --resolve $domain:443:127.0.0.1 https://$domain$path_url/ -o /dev/null --write-out "%{http_code}" --retry 10 --retry-delay 3
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
|
@ -327,6 +326,13 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
|||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# WAITING FOR SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Waiting for service..." --weight=1
|
||||
|
||||
is_service_ready
|
||||
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
|
|
Loading…
Reference in a new issue