From 8e2027b5ee71ceebe97818dde1969d893e00e8c5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 2 Feb 2019 00:33:42 +0100 Subject: [PATCH] Fix Service logs --- conf/systemd.service | 3 ++- scripts/install | 16 +++++++++++----- scripts/restore | 7 +++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index e082ffe..e8d2327 100755 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,8 +5,9 @@ After=network.target [Service] Type=simple User=__APP__ +Group=__APP__ WorkingDirectory=__FINALPATH__/__APP__ -ExecStart=__FINALPATH__/.cargo/bin/plume +ExecStart=/bin/sh -c '__FINALPATH__/.cargo/bin/plume >> /var/log/__APP__/__APP__.log 2>&1' TimeoutSec=30 Restart=always diff --git a/scripts/install b/scripts/install index f5d44e2..4a650de 100755 --- a/scripts/install +++ b/scripts/install @@ -181,13 +181,17 @@ ynh_system_user_create "$app" "$final_path" #================================================= # SPECIFIC SETUP #================================================= -# ... +# CREATE LOG FOLDER #================================================= -# setup application config -sudo cp ../conf/.env $final_path/$app/.env + +mkdir -p "/var/log/$app" +chown -R "$app":"$app" "/var/log/$app" + #================================================= # MODIFY A CONFIG FILE #================================================= +# setup application config +sudo cp "../conf/.env" "$final_path/$app/.env" ynh_replace_string "__DBNAME__" "$db_name" "$final_path/$app/.env" ynh_replace_string "__PSQLPWD__" "$db_pwd" "$final_path/$app/.env" ynh_replace_string "__DOMAIN__" "$domain" "$final_path/$app/.env" @@ -195,10 +199,12 @@ ynh_replace_string "__PORT__" "$port" "$final_path/$app/.env" ynh_replace_string "__DB_USER__" "$app" "$final_path/$app/.env" ynh_replace_string "__KEY__" "$random_key" "$final_path/$app/.env" +#================================================= +# MAKE SETUP +#================================================= # Set right permissions -chown -R $app: $final_path - +chown -R "$app":"$app" $final_path # App settings ( cd $final_path && sudo -u "$app" RUSTUP_HOME=$final_path/.rustup CARGO_HOME=$final_path/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=nightly' ) diff --git a/scripts/restore b/scripts/restore index e343dc3..8691894 100755 --- a/scripts/restore +++ b/scripts/restore @@ -104,6 +104,7 @@ ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git ynh_restore_file "/etc/systemd/system/$app.service" systemctl enable $app.service +systemctl daemon-reload #Fix Your search index is locked. @@ -136,6 +137,12 @@ 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