Be more robust against broken config or service failing to start, show info to help debugging

This commit is contained in:
Alexandre Aubin 2020-04-21 04:48:13 +02:00
parent 01a6aa1371
commit 34fd4e90bd

View file

@ -26,7 +26,8 @@ do_init_regen() {
ynh_render_template "yunohost_admin.conf" "${nginx_conf_dir}/yunohost_admin.conf" ynh_render_template "yunohost_admin.conf" "${nginx_conf_dir}/yunohost_admin.conf"
# Restart nginx if conf looks good, otherwise display error and exit unhappy # Restart nginx if conf looks good, otherwise display error and exit unhappy
nginx -t 2>/dev/null && service nginx restart || (nginx -t && exit 1) nginx -t 2>/dev/null || { nginx -t; exit 1; }
systemctl restart nginx || { journalctl --no-pager --lines=10 -u nginx >&2; exit 1; }
exit 0 exit 0
} }
@ -109,8 +110,9 @@ do_post_regen() {
mkdir -p "/etc/nginx/conf.d/${domain}.d" mkdir -p "/etc/nginx/conf.d/${domain}.d"
done done
# Reload nginx configuration # Reload nginx if conf looks good, otherwise display error and exit unhappy
pgrep nginx && service nginx reload nginx -t 2>/dev/null || { nginx -t; exit 1; }
pgrep nginx && systemctl reload nginx || { journalctl --no-pager --lines=10 -u nginx >&2; exit 1; }
} }
FORCE=${2:-0} FORCE=${2:-0}