diff --git a/conf/systemd.service b/conf/systemd.service index fafe06a..ddffa87 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -9,7 +9,7 @@ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ Environment="PATH=__ENV_PATH__" Environment="NODE_ENV=production" -ExecStart=__YNH_NPM__ start +ExecStart=__YNH_NPM__ run build Restart=on-failure RestartSec=5 StartLimitInterval=60s diff --git a/scripts/install b/scripts/install index b25d7b2..6584f75 100755 --- a/scripts/install +++ b/scripts/install @@ -36,6 +36,12 @@ ynh_script_progression --message="Adding system configurations related to $app.. # Create a dedicated NGINX config using the conf/nginx.conf template ynh_add_nginx_config +# Create a dedicated systemd config +env_path="$PATH" +ynh_add_systemd_config + +yunohost service add $app --description="ChatGPT web interface" --log="/var/log/$app/$app.log" + #================================================= # APP INITIAL CONFIGURATION #================================================= @@ -57,10 +63,18 @@ ynh_script_progression --message="Building app... (this will take some time and pushd "$install_dir" ynh_use_nodejs - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH npm ci - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH npm run build + ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH npm ci + #ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH npm run build popd +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 55ee0f9..7dde3fa 100755 --- a/scripts/restore +++ b/scripts/restore @@ -31,7 +31,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="ChatGPT web interface" --log="/var/log/$app/$app.log" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index f3eb8a8..83b6a6f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,7 +29,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" + ynh_setup_source --dest_dir="$install_dir" --keep = ".env" fi chown -R $app:www-data "$install_dir" @@ -41,9 +41,16 @@ ynh_script_progression --message="Upgrading system configurations related to $ap ynh_add_nginx_config +env_path="$PATH" ynh_add_systemd_config -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="ChatGPT web interface" --log="/var/log/$app/$app.log" + +pushd "$install_dir" + ynh_use_nodejs + ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH npm ci + #ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH npm run build +popd #================================================= # START SYSTEMD SERVICE