From 3101a0480ce49cf1e7cb51bfe4acaf1a874efdb5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 15:47:49 +0200 Subject: [PATCH] Implementing ynh_systemd_action --- scripts/backup | 1 - scripts/install | 7 +++---- scripts/remove | 4 +++- scripts/restore | 11 +++++++++-- scripts/upgrade | 14 +++++++------- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/scripts/backup b/scripts/backup index fbb59fb..f0b3ddb 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,7 +28,6 @@ final_path=$(ynh_app_setting_get "$app" final_path) domain=$(ynh_app_setting_get "$app" domain) db_name=$(ynh_app_setting_get "$app" db_name) - #================================================= # STANDARD BACKUP STEPS #================================================= diff --git a/scripts/install b/scripts/install index 6cb7220..45a7b57 100644 --- a/scripts/install +++ b/scripts/install @@ -200,8 +200,6 @@ ynh_add_systemd_config "$app-server" "funkwhale-server.service" ynh_add_systemd_config "$app-worker" "funkwhale-worker.service" ynh_add_systemd_config "$app-beat" "funkwhale-beat.service" -systemctl restart "$app".target - #================================================= # GENERIC FINALIZATION #================================================= @@ -220,7 +218,6 @@ chown -R "$app": "/var/log/$app" ynh_add_fail2ban_config "/var/log/nginx/$domain-access.log" ".* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" 5 - #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= @@ -253,7 +250,9 @@ systemctl reload nginx #================================================= ynh_print_info "Start Services..." -systemctl start "$app-server" "$app-worker" "$app-beat" +ynh_systemd_action --action=start --service_name=${app}-beat --log_path=systemd --line_match="celery beat process" +ynh_systemd_action --action=start --service_name=${app}-server --log_path=systemd --line_match="Listening on TCP address" +ynh_systemd_action --action=start --service_name=${app}-worker --log_path=systemd --line_match="celery worker" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index c0ec4f6..771ad7b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -53,7 +53,9 @@ fi #================================================= ynh_print_info "Stopping and removing the systemd service" -systemctl stop "$app".target +ynh_systemd_action --action=stop --service_name=${app}-beat --log_path=systemd --line_match="Stopped Funkwhale" +ynh_systemd_action --action=stop --service_name=${app}-server --log_path=systemd --line_match="Stopped Funkwhale" +ynh_systemd_action --action=stop --service_name=${app}-worker --log_path=systemd --line_match="Stopped Funkwhale" # Remove the dedicated systemd config ynh_remove_systemd_config "$app-server" diff --git a/scripts/restore b/scripts/restore index c9742c6..b9da64a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -130,7 +130,6 @@ ynh_restore_file "/etc/systemd/system/$app.target" systemctl enable "$app-beat.service" systemctl enable "$app-server.service" systemctl enable "$app-worker.service" -systemctl restart "$app.target" #================================================= # ADVERTISE SERVICE IN ADMIN PANEL @@ -147,9 +146,17 @@ yunohost service add "$app-beat" --log "/var/log/$app/beat.log" #================================================= ynh_print_info "Reloading nginx web server..." - systemctl reload nginx +#================================================= +# START SERVICES +#================================================= +ynh_print_info "Start Services..." + +ynh_systemd_action --action=start --service_name=${app}-beat --log_path=systemd --line_match="celery beat process" +ynh_systemd_action --action=start --service_name=${app}-server --log_path=systemd --line_match="Listening on TCP address" +ynh_systemd_action --action=start --service_name=${app}-worker --log_path=systemd --line_match="celery worker" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 27ec307..3ad265a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -74,9 +74,9 @@ ynh_abort_if_errors #================================================= ynh_print_info "Stopping $app services..." -systemctl stop "$app-beat.service" -systemctl stop "$app-server.service" -systemctl stop "$app-worker.service" +ynh_systemd_action --action=stop --service_name=${app}-beat --log_path=systemd --line_match="Stopped Funkwhale" +ynh_systemd_action --action=stop --service_name=${app}-server --log_path=systemd --line_match="Stopped Funkwhale" +ynh_systemd_action --action=stop --service_name=${app}-worker --log_path=systemd --line_match="Stopped Funkwhale" #================================================= # CHECK THE PATH @@ -238,8 +238,6 @@ ynh_add_systemd_config "$app-server" "funkwhale-server.service" ynh_add_systemd_config "$app-worker" "funkwhale-worker.service" ynh_add_systemd_config "$app-beat" "funkwhale-beat.service" -systemctl restart "$app".target - #================================================= # GENERIC FINALIZATION #================================================= @@ -286,9 +284,11 @@ ynh_app_setting_set "$app" code_migration 2 #================================================= # START SERVICES #================================================= -ynh_print_info "Starting $app services..." +ynh_print_info "Start Services..." -systemctl restart "$app.target" +ynh_systemd_action --action=start --service_name=${app}-beat --log_path=systemd --line_match="celery beat process" +ynh_systemd_action --action=start --service_name=${app}-server --log_path=systemd --line_match="Listening on TCP address" +ynh_systemd_action --action=start --service_name=${app}-worker --log_path=systemd --line_match="celery worker" #================================================= # END OF SCRIPT