From ca46b19f560989cc9c60b93ad9d27b934f550570 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 2 Feb 2019 00:33:52 +0100 Subject: [PATCH] Fix Service logs --- conf/systemd.service | 3 ++- scripts/install | 8 +++++--- scripts/restore | 7 ++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 03754c5..c634d59 100755 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,9 +5,10 @@ After=network.target postgresql.service [Service] Environment="MIX_ENV=prod" User=__APP__ +Group=__APP__ WorkingDirectory=__FINALPATH__/__APP__ Environment="HOME=__FINALPATH__" -ExecStart=/usr/bin/mix phx.server +ExecStart=/bin/sh -c '/usr/bin/mix phx.server >> /var/log/__APP__/__APP__.log 2>&1' ExecReload=/bin/kill $MAINPID KillMode=process Restart=on-failure diff --git a/scripts/install b/scripts/install index 85d5ec0..f563859 100755 --- a/scripts/install +++ b/scripts/install @@ -215,9 +215,12 @@ ynh_system_user_create "$app" "$final_path" #================================================= # SPECIFIC SETUP #================================================= -# ... +# CREATE LOG FOLDER #================================================= +mkdir -p "/var/log/$app" +chown -R "$app":"$app" "/var/log/$app" + #================================================= # MODIFY A CONFIG FILE #================================================= @@ -248,9 +251,8 @@ else ynh_replace_string "__REG__" "false" "$final_path/$app/config/prod.secret.exs" fi - #================================================= -# SETUP +# MAKE SETUP #================================================= # Give permission to the final_path chown -R "$app":"$app" "$final_path" diff --git a/scripts/restore b/scripts/restore index d9fdfed..1769a36 100755 --- a/scripts/restore +++ b/scripts/restore @@ -104,7 +104,6 @@ chown -R "$app":"$app" "$final_path" # REINSTALL DEPENDENCIES #================================================= - # Add erlang for Debian Jessie if [ "$(lsb_release --codename --short)" == "jessie" ]; then @@ -154,6 +153,12 @@ ynh_restore_file "/etc/logrotate.d/$app" systemctl reload nginx +#================================================= +# CREATE LOG FOLDER +#================================================= + +mkdir -p "/var/log/$app" +chown -R "$app":"$app" "/var/log/$app" #================================================= # START SERVICE