diff --git a/conf/systemd.service b/conf/systemd.service new file mode 100644 index 0000000..0d2d249 --- /dev/null +++ b/conf/systemd.service @@ -0,0 +1,11 @@ +[Unit] +Description=ttrss_backend +After=network.target mysql.service + +[Service] +User=__APP__ +Group=__APP__ +ExecStart=/usr/bin/php __FINALPATH__/update_daemon2.php + +[Install] +WantedBy=multi-user.target diff --git a/scripts/install b/scripts/install index 9da2e4b..7ed2c24 100644 --- a/scripts/install +++ b/scripts/install @@ -109,11 +109,10 @@ ynh_replace_string "__DOMAINPATH__" "https://$domain$path_url" "$final_path/conf ynh_store_file_checksum "$final_path/config.php" #================================================= -# ADD A CRON FILE +# SETUP SYSTEMD #================================================= -echo "*/30 * * * * $app cd $final_path && /usr/bin/php $final_path/update.php --feeds >/dev/null 2>&1" \ - > /etc/cron.d/$app +ynh_add_systemd_config #================================================= # SECURE FILES AND DIRECTORIES @@ -132,6 +131,12 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \ sudo -u $app php ${final_path}/update.php --update-schema +#================================================= +# START TTRSS IN BACKGROUND +#================================================= + +sudo systemctl start $app + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/remove b/scripts/remove index 9bc7ab5..fe5d506 100644 --- a/scripts/remove +++ b/scripts/remove @@ -59,11 +59,10 @@ ynh_remove_fpm_config #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE THE CRON FILE +# STOP AND REMOVE SERVICE #================================================= -# Remove a cron file -ynh_secure_remove "/etc/cron.d/$app" +ynh_remove_systemd_config #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 5b0b846..9c2c9e9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -101,13 +101,6 @@ ynh_replace_string "__DOMAINPATH__" "https://$domain$path_url" "$final_path/conf # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/config.php" -#================================================= -# UPGRADE THE CRON FILE -#================================================= - -echo "*/30 * * * * $app cd $final_path && /usr/bin/php $final_path/update.php --feeds >/dev/null 2>&1" \ - > /etc/cron.d/$app - #================================================= # UPGRADE DATABASE #================================================= @@ -123,6 +116,20 @@ sudo -u $app php ${final_path}/update.php --update-schema chown -R root: $final_path chown -R $app $final_path/{cache,feed-icons,lock} +#================================================= +# REMOVE OLD CRON JOB +#================================================= + +ynh_secure_remove "/etc/cron.d/$app" + +#================================================= +# UPGRADE SERVICE +#================================================= + +ynh_add_systemd_config +sudo systemctl daemon-reload +sudo systemctl restart $app + #================================================= # GENERIC FINALIZATION #=================================================