From 73157c33037ffb078b2eba8c66bfb2787ad9946b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 25 May 2018 22:12:51 +0200 Subject: [PATCH] add ynh_system_reload for debug --- scripts/change_url | 2 +- scripts/experimental_helper.sh | 13 +++++++++++++ scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index a2cc4bc..bac4d60 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -140,4 +140,4 @@ sleep 1 # Reload services sudo systemctl reload nginx.service -sudo systemctl start seafile-server.service +ynh_system_reload seafile-server start \ No newline at end of file diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index d4e73f5..f4c9ee7 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -127,3 +127,16 @@ 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 803576f..2999cb5 100644 --- a/scripts/install +++ b/scripts/install @@ -191,4 +191,4 @@ sleep 2 pkill -f seafile-controller || true pkill -f seaf-server || true -systemctl start seafile-server.service +ynh_system_reload seafile-server start \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index 4a7b02b..3e1f831 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 -systemctl start seafile-server.service +ynh_system_reload seafile-server start \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index ce23311..e14f428 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -162,7 +162,7 @@ chown -R $seafile_user:$seafile_user $final_path ynh_secure_remove /tmp/seahub_cache # restart seafile server -systemctl start seafile-server.service +ynh_system_reload seafile-server start # remove old version files ls $final_path | grep "seafile-server-" | egrep -v "(${seafile_version//./\\.})|(latest)" | \