diff --git a/scripts/_common.sh b/scripts/_common.sh index 567bcb9..7bd3665 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -67,3 +67,20 @@ ynh_clean_setup () { pkill -f ccnet-server pkill -f "seahub" } + +# Reload (or other actions) a service and print a log in case of failure. +# +# usage: system_reload service_name [action] +# | arg: service_name - Name of the service to reload +# | arg: action - Action to perform with systemctl. Default: reload +system_reload () { + local service_name=$1 + local action=${2:-reload} + + # Reload, restart or start and print the log if the service fail to start or reload + systemctl $action $service_name || ( + journalctl --lines=20 -u $service_name >&2 + tail -n 50 $final_path/logs/*.log + false + ) +} diff --git a/scripts/change_url b/scripts/change_url index 095919b..f7f19ab 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -61,6 +61,11 @@ ynh_add_nginx_config 'seahub_port fileserver_port webdav_port' # Stop service before any change sudo systemctl stop seafile-server.service +sleep 2 +pkill -f seafile-controller || true +pkill -f seaf-server || true +pkill -f ccnet-server || true +pkill -f seahub || true # Update Seafile Config ynh_replace_string "SERVICE_URL = https://$old_domain$old_path" "SERVICE_URL = https://$domain$path_url" $final_path/conf/ccnet.conf @@ -136,8 +141,8 @@ mysql_relpace_db seahubdb two_factor_totpdevice user mysql_relpace_db seahubdb wiki_personalwiki username # Avoid the current effect -sleep 5 +sleep 2 # Reload services sudo systemctl reload nginx.service -ynh_system_reload seafile-server start \ No newline at end of file +system_reload seafile-server start \ No newline at end of file diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index f4c9ee7..d4e73f5 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -127,16 +127,3 @@ ynh_delete_file_checksum () { local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' ynh_app_setting_delete $app $checksum_setting_name } - -# Reload (or other actions) a service and print a log in case of failure. -# -# usage: ynh_system_reload service_name [action] -# | arg: service_name - Name of the service to reload -# | arg: action - Action to perform with systemctl. Default: reload -ynh_system_reload () { - local service_name=$1 - local action=${2:-reload} - - # Reload, restart or start and print the log if the service fail to start or reload - systemctl $action $service_name || ( journalctl --lines=20 -u $service_name >&2 && false) -} diff --git a/scripts/install b/scripts/install index 2999cb5..13a36e0 100644 --- a/scripts/install +++ b/scripts/install @@ -191,4 +191,4 @@ sleep 2 pkill -f seafile-controller || true pkill -f seaf-server || true -ynh_system_reload seafile-server start \ No newline at end of file +system_reload seafile-server start \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index 3e1f831..6a770e4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -72,4 +72,4 @@ systemctl reload nginx.service # Enable service and start seafile systemctl daemon-reload update-rc.d seafile-server defaults -ynh_system_reload seafile-server start \ No newline at end of file +system_reload seafile-server start \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 61b3b53..a140667 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,6 +31,11 @@ get_configuration # stop seafile server systemctl stop seafile-server.service +sleep 2 +pkill -f seafile-controller || true +pkill -f seaf-server || true +pkill -f ccnet-server || true +pkill -f seahub || true #================================================= # MIGRATION FROM OLD VERSION @@ -163,7 +168,7 @@ ynh_secure_remove /tmp/seahub_cache # restart seafile server sleep 5 -ynh_system_reload seafile-server start +system_reload seafile-server start # remove old version files ls $final_path | grep "seafile-server-" | egrep -v "(${seafile_version//./\\.})|(latest)" | \