From 59f489dfd086261b78a44c1aab0f7c80e237b549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 12 Jun 2023 16:53:23 +0200 Subject: [PATCH] Configure logging to /var/log/ihatemoney --- conf/systemd.service | 4 ++++ scripts/backup | 6 ++++++ scripts/install | 4 ++++ scripts/restore | 6 ++++++ scripts/upgrade | 7 +++++++ 5 files changed, 27 insertions(+) diff --git a/conf/systemd.service b/conf/systemd.service index 5803179..188a939 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,10 +6,14 @@ After=network.target mysql.service [Service] Type=simple User=__APP__ +Group=__APP__ Environment=IHATEMONEY_SETTINGS_FILE_PATH=__FINALPATH__/ihatemoney.cfg ExecStart=__FINALPATH__/venv/bin/gunicorn -c __FINALPATH__/gunicorn.conf.py ihatemoney.wsgi:application Restart=always RestartSec=2 +StandardOutput=append:/var/log/__APP__/__APP__.log +StandardError=inherit + [Install] WantedBy=multi-user.target diff --git a/scripts/backup b/scripts/backup index 1f7aec4..9b97f39 100755 --- a/scripts/backup +++ b/scripts/backup @@ -53,6 +53,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/systemd/system/$app.service" +#================================================= +# BACKUP LOG +#================================================= + +ynh_backup --src_path="/var/log/$app" --is_big=1 + #================================================= # BACKUP THE MYSQL DATABASE #================================================= diff --git a/scripts/install b/scripts/install index 8aafc84..a5114bf 100755 --- a/scripts/install +++ b/scripts/install @@ -134,6 +134,10 @@ ynh_add_config --template="../conf/ihatemoney.cfg" --destination="$final_path/ih chmod 640 "$final_path/ihatemoney.cfg" chown $app:$app "$final_path/ihatemoney.cfg" +# Configure log directory +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" + #================================================= # SETUP SYSTEMD #================================================= diff --git a/scripts/restore b/scripts/restore index e1beb8d..90f73fe 100755 --- a/scripts/restore +++ b/scripts/restore @@ -96,6 +96,12 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet +#================================================= +# RESTORE LOG +#================================================= + +ynh_restore_file --origin_path="/var/log/$app" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 0c0c71c..85c9c91 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -130,6 +130,13 @@ if [ -z "$hashed_password" ] && [ test -f "${final_path}/venv/bin/activate" ]; t ynh_send_readme_to_admin --app_message="../conf/upgrade.msg" --type="upgrade" fi +if [ ! -d "/var/log/$app" ]; then + # Configure log directory + mkdir -p "/var/log/$app" + chown -R $app:$app "/var/log/$app" +fi + + #================================================= # CREATE DEDICATED USER #=================================================