1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ttrss_ynh.git synced 2024-10-01 13:34:46 +02:00

[enh] switch from cron job to systemd service for feed fetching

This commit is contained in:
ariasuni 2017-08-27 16:42:26 +02:00
parent bcc85d86bf
commit ba9534b58b
6 changed files with 40 additions and 17 deletions

11
conf/systemd.service Normal file
View file

@ -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

View file

@ -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"

View file

@ -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
#=================================================

View file

@ -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

View file

@ -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

View file

@ -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
#=================================================