diff --git a/conf/movim.service b/conf/systemd.service similarity index 65% rename from conf/movim.service rename to conf/systemd.service index 85950f1..2b90155 100644 --- a/conf/movim.service +++ b/conf/systemd.service @@ -1,15 +1,15 @@ [Unit] -Description=Movim daemon +Description=Movim daemon (__APP__) After=nginx.service network.target local-fs.target mysql.service [Service] -User=movim Type=simple +User=__APP__ +Group=__APP__ +WorkingDirectory=__FINALPATH__/ ExecStart=/usr/bin/php daemon.php start --url=https://YHURL --port=YHPORT -WorkingDirectory=YHDIR StandardOutput=syslog -SyslogIdentifier=movim -PIDFile=/run/movim.pid +SyslogIdentifier=__APP__ [Install] WantedBy=multi-user.target diff --git a/scripts/install b/scripts/install index 219138e..6c9b363 100644 --- a/scripts/install +++ b/scripts/install @@ -182,15 +182,10 @@ exec_cmd php mud.php config --loglevel=1 \ # SETUP SYSTEMD #================================================= -# Copy init script or systemd service -ynh_replace_string "YHURL" "${domain}${path_url}" ../conf/movim.service -ynh_replace_string "YHDIR" "${final_path}" ../conf/movim.service -ynh_replace_string "YHPORT" "${port}" ../conf/movim.service - -cp ../conf/movim.service /etc/systemd/system/ -systemctl daemon-reload -systemctl enable movim.service -systemctl start movim.service +# Create a dedicated systemd config +ynh_replace_string "__URL__" "${domain}${path_url}" ../conf/systemd.service +ynh_replace_string "__PORT__" "${port}" ../conf/systemd.service +ynh_add_systemd_config #================================================= # GENERIC FINALIZATION diff --git a/scripts/remove b/scripts/remove index b9139c4..abff694 100644 --- a/scripts/remove +++ b/scripts/remove @@ -38,11 +38,8 @@ ynh_remove_fpm_config # STOP AND REMOVE SERVICE #================================================= -service movim stop - -systemctl --quiet disable movim.service -ynh_secure_remove /lib/systemd/system/movim.service -systemctl --quiet daemon-reload +# Remove the dedicated systemd config +ynh_remove_systemd_config #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/upgrade b/scripts/upgrade index 1c6adbe..71f3c05 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -167,13 +167,10 @@ fi # SETUP SYSTEMD #================================================= -ynh_replace_string "YHURL" "${domain}${path_url}" ../conf/movim.service -ynh_replace_string "YHDIR" "${final_path}" ../conf/movim.service -ynh_replace_string "YHPORT" "${port}" ../conf/movim.service - -ynh_secure_remove /lib/systemd/system/movim.service -cp ../conf/movim.service /etc/systemd/system/ -systemctl daemon-reload +# Create a dedicated systemd config +ynh_replace_string "__URL__" "${domain}${path_url}" ../conf/systemd.service +ynh_replace_string "__PORT__" "${port}" ../conf/systemd.service +ynh_add_systemd_config #================================================= # RELOAD SERVICES