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/backup b/scripts/backup index c5bf1b7..135f307 100644 --- a/scripts/backup +++ b/scripts/backup @@ -61,7 +61,7 @@ ynh_mysql_dump_db "$db_name" > db.sql #================================================= # SPECIFIC BACKUP #================================================= -# BACKUP THE CRON FILE +# BACKUP SYSTEMD #================================================= -ynh_backup "/etc/cron.d/$app" "${YNH_APP_BACKUP_DIR}/etc/cron.d/$app" +ynh_backup "/etc/systemd/system/$app.service" "${YNH_APP_BACKUP_DIR}/etc/systemd/system/$app.service" diff --git a/scripts/install b/scripts/install index 985ba27..3fc564f 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 979de26..a09e254 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/restore b/scripts/restore index 3e6fc1d..7107558 100644 --- a/scripts/restore +++ b/scripts/restore @@ -95,10 +95,12 @@ ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" ynh_install_app_dependencies php5-cli #================================================= -# RESTORE THE CRON FILE +# RESTORE SYSTEMD #================================================= -ynh_restore_file "/etc/cron.d/$app" +ynh_restore_file "/etc/systemd/system/$app.service" +## Démarrage auto du service +sudo systemctl enable $app.service #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 3f5b260..160af05 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,19 @@ 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 restart $app + #================================================= # GENERIC FINALIZATION #=================================================