From cb0e1127223863bc86ad49645e46798e48a4336b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 8 Feb 2019 18:24:05 +0100 Subject: [PATCH] Switch from log files to journalctl --- conf/systemd.service | 7 +++++-- scripts/backup | 2 +- scripts/install | 11 ++--------- scripts/remove | 4 ++-- scripts/restore | 11 ++--------- scripts/upgrade | 2 +- 6 files changed, 13 insertions(+), 24 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index b2cdfdf..8399c8b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,8 +6,11 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=/bin/sh -c '__FINALPATH__/writefreely >> /var/log/__APP__/__APP__.log 2>&1' +StandardOutput=syslog +StandardError=syslog +WorkingDirectory=__FINALPATH__ +ExecStart=__FINALPATH__/writefreely +Restart=always [Install] WantedBy=multi-user.target diff --git a/scripts/backup b/scripts/backup index e35094e..015ed04 100755 --- a/scripts/backup +++ b/scripts/backup @@ -73,7 +73,7 @@ ynh_mysql_dump_db "$db_name" > db.sql # BACKUP LOGROTATE #================================================= -ynh_backup "/etc/logrotate.d/$app" +#ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD diff --git a/scripts/install b/scripts/install index 2cfa69a..765347b 100755 --- a/scripts/install +++ b/scripts/install @@ -288,13 +288,6 @@ ynh_store_file_checksum "$final_path/config.ini" #================================================= # SPECIFIC SETUP -#================================================= -# CREATE LOG FOLDER -#================================================= - -mkdir -p "/var/log/$app" -chown -R "$app":"$app" "/var/log/$app" - #================================================= # MAKE SETUP #================================================= @@ -333,7 +326,7 @@ chown -R "$app":"$app" "$final_path" ### - And the section "SETUP LOGROTATE" in the upgrade script # Use logrotate to manage application logfile(s) -ynh_use_logrotate +#ynh_use_logrotate #================================================= # ADVERTISE SERVICE IN ADMIN PANEL @@ -350,7 +343,7 @@ ynh_use_logrotate #yunohost service add $app --log "/var/log/$app/APP.log" # if using yunohost version 3.2 or more in the 'manifest.json', a description can be added -yunohost service add $app --description "$app daemon for WriteFreely" --log "/var/log/$app/$app.log" +yunohost service add $app --description "$app daemon for WriteFreely" --log_type systemd #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index e2cca67..6ffffcc 100755 --- a/scripts/remove +++ b/scripts/remove @@ -91,7 +91,7 @@ ynh_remove_nginx_config #================================================= # Remove the app-specific logrotate config -ynh_remove_logrotate +#ynh_remove_logrotate #================================================= # CLOSE A PORT @@ -116,7 +116,7 @@ fi ynh_secure_remove "/etc/$app/" # Remove the log files -ynh_secure_remove "/var/log/$app/" +#ynh_secure_remove "/var/log/$app/" #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index 06a1fb5..ef76183 100755 --- a/scripts/restore +++ b/scripts/restore @@ -114,7 +114,7 @@ systemctl daemon-reload # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add $app --description "$app daemon for WriteFreely" --log "/var/log/$app/$app.log" +yunohost service add $app --description "$app daemon for WriteFreely" --log_type systemd #================================================= # RESTORE THE CRON FILE @@ -126,7 +126,7 @@ yunohost service add $app --description "$app daemon for WriteFreely" --log "/va # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_restore_file "/etc/logrotate.d/$app" +#ynh_restore_file "/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION @@ -137,13 +137,6 @@ ynh_restore_file "/etc/logrotate.d/$app" #systemctl reload php5-fpm systemctl reload nginx -#================================================= -# CREATE LOG FOLDER -#================================================= - -mkdir -p "/var/log/$app" -chown -R "$app":"$app" "/var/log/$app" - #================================================= # START SERVICE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c248a83..ca71c31 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -166,7 +166,7 @@ fi #================================================= # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +#ynh_use_logrotate --non-append #================================================= # SETUP SYSTEMD