From 85fbd43466ad82c1a6189ce6159089c05b7885f6 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 | 5 +++++ scripts/install | 4 ++++ scripts/upgrade | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/conf/systemd.service b/conf/systemd.service index 094ca37..14513a8 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,10 +6,15 @@ After=network.target mysql.service [Service] Type=simple User=__APP__ +Group=__APP__ +WorkingDirectory=__INSTALL_DIR__/ Environment=IHATEMONEY_SETTINGS_FILE_PATH=__INSTALL_DIR__/ihatemoney.cfg ExecStart=__INSTALL_DIR__/venv/bin/gunicorn -c __INSTALL_DIR__/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/install b/scripts/install index c9813aa..712cb18 100755 --- a/scripts/install +++ b/scripts/install @@ -64,6 +64,10 @@ ynh_add_config --template="../conf/ihatemoney.cfg" --destination="$install_dir/i chmod 640 "$install_dir/ihatemoney.cfg" chown $app:$app "$install_dir/ihatemoney.cfg" +# Configure log directory +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" + #================================================= # SETUP SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 5820447..3dac496 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -91,6 +91,13 @@ if [ -z "$hashed_password" ] && [ test -f "${install_dir}/venv/bin/activate" ]; ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password fi +if [ ! -d "/var/log/$app" ]; then + # Configure log directory + mkdir -p "/var/log/$app" + chown -R $app:$app "/var/log/$app" +fi + + #================================================= # SPECIFIC UPGRADE #=================================================