fix ynh_systemd_action in case of service fails

This commit is contained in:
Kay0u 2021-02-25 11:16:34 +01:00 committed by Alexandre Aubin
parent d12f403fe3
commit 05969184fe

View file

@ -92,7 +92,7 @@ ynh_remove_systemd_config () {
# usage: ynh_systemd_action [--service_name=service_name] [--action=action] [ [--line_match="line to match"] [--log_path=log_path] [--timeout=300] [--length=20] ] # usage: ynh_systemd_action [--service_name=service_name] [--action=action] [ [--line_match="line to match"] [--log_path=log_path] [--timeout=300] [--length=20] ]
# | arg: -n, --service_name= - Name of the service to start. Default : $app # | arg: -n, --service_name= - Name of the service to start. Default : $app
# | arg: -a, --action= - Action to perform with systemctl. Default: start # | arg: -a, --action= - Action to perform with systemctl. Default: start
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started. WARNING: When using --line_match, you should always add `ynh_clean_check_starting` into your `ynh_clean_setup` at the beginning of the script. Otherwise, tail will not stop in case of failure of the script. The script will then hang forever. # | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started.
# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log # | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. # | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
# | arg: -e, --length= - Length of the error log : Default : 20 # | arg: -e, --length= - Length of the error log : Default : 20
@ -151,6 +151,7 @@ ynh_systemd_action() {
then then
ynh_exec_err tail --lines=$length "$log_path" ynh_exec_err tail --lines=$length "$log_path"
fi fi
ynh_clean_check_starting
return 1 return 1
fi fi
@ -195,9 +196,8 @@ ynh_systemd_action() {
} }
# Clean temporary process and file used by ynh_check_starting # Clean temporary process and file used by ynh_check_starting
# (usually used in ynh_clean_setup scripts)
# #
# usage: ynh_clean_check_starting # [internal]
# #
# Requires YunoHost version 3.5.0 or higher. # Requires YunoHost version 3.5.0 or higher.
ynh_clean_check_starting () { ynh_clean_check_starting () {
@ -208,7 +208,7 @@ ynh_clean_check_starting () {
fi fi
if [ -n "$templog" ] if [ -n "$templog" ]
then then
ynh_secure_remove "$templog" 2>&1 ynh_secure_remove --file="$templog" 2>&1
fi fi
} }