From a34c416e3c9f0f33ac73f9b8886145c0583d58b9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 12 Apr 2022 23:16:46 +0200 Subject: [PATCH] Manage logs --- conf/caldav.ini | 1 - conf/web.ini | 3 --- conf/webdav.ini | 1 - scripts/backup | 7 +------ scripts/change_url | 6 +++--- scripts/install | 17 ++++------------- scripts/remove | 18 +----------------- scripts/restore | 13 +++---------- scripts/upgrade | 25 +++++-------------------- 9 files changed, 17 insertions(+), 74 deletions(-) diff --git a/conf/caldav.ini b/conf/caldav.ini index f9896b0..133b9b6 100644 --- a/conf/caldav.ini +++ b/conf/caldav.ini @@ -9,4 +9,3 @@ threads = 8 env = TRACIM_CONF_PATH=__FINALPATH__/backend/development.ini socket = /tmp/uwsgi-__APP__-caldav.socket chmod-socket = 660 -logto = /var/log/__APP__/__APP__-caldav.log diff --git a/conf/web.ini b/conf/web.ini index fec7379..712d24c 100644 --- a/conf/web.ini +++ b/conf/web.ini @@ -10,6 +10,3 @@ chmod-socket = 660 workers = 4 threads = 4 env = TRACIM_CONF_PATH=__FINALPATH__/backend/development.ini -logto = /var/log/__APP__/__APP__-web.log - - diff --git a/conf/webdav.ini b/conf/webdav.ini index 7faa0b3..f262a62 100644 --- a/conf/webdav.ini +++ b/conf/webdav.ini @@ -9,4 +9,3 @@ threads = 8 env = TRACIM_CONF_PATH=__FINALPATH__/backend/development.ini socket = /tmp/uwsgi-__APP__-webdav.socket chmod-socket = 660 -logto = /var/log/__APP__/__APP__-webdav.log diff --git a/scripts/backup b/scripts/backup index b3f2b18..f0fa30f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -54,14 +54,9 @@ ynh_backup --src_path="$datadir" --is_big #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - -ynh_backup --src_path="/etc/logrotate.d/$app" - #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/change_url b/scripts/change_url index 8d704a7..31a5a68 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -82,7 +82,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_supervisor_action --service_name=$app --action="stop" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" +ynh_supervisor_action --service_name=$app --action="stop" --log_path="/var/log/supervisor/supervisord.log" #================================================= # MODIFY URL IN NGINX CONF @@ -139,8 +139,8 @@ chown $app:$app "$final_path/frontend/configEnv.json" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" -ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" +ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app.log" --line_match="spawned uWSGI" +ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index e702c43..4e1dcd5 100755 --- a/scripts/install +++ b/scripts/install @@ -190,6 +190,7 @@ pushd "$final_path" popd ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_package_autoremove chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -220,22 +221,12 @@ ln -sf /etc/uwsgi/apps-available/$app-caldav.ini /etc/uwsgi/apps-enabled/$app-ca #================================================= # GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." - -mkdir -p "/var/log/$app" -chown -R $app:$app "/var/log/$app" -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add uwsgi --log="/var/log/uwsgi/$app/$app.log" +yunohost service add uwsgi --log="/var/log/uwsgi/app/$app.log" yunohost service add supervisor --log="/var/log/supervisor/supervisord.log" #================================================= @@ -244,8 +235,8 @@ yunohost service add supervisor --log="/var/log/supervisor/supervisord.log" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" -ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" +ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app.log" --line_match="spawned uWSGI" +ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 0f81f72..ed52b56 100755 --- a/scripts/remove +++ b/scripts/remove @@ -61,15 +61,7 @@ ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-webdav.ini" ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-webdav.ini" ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-caldav.ini" ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-caldav.ini" -ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" - -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." - -# Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app.log" --line_match="spawned uWSGI" #================================================= # REMOVE THE POSTGRESQL DATABASE @@ -117,14 +109,6 @@ ynh_remove_app_dependencies #================================================= # SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." - -# Remove the log files -ynh_secure_remove --file="/var/log/$app" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index a6beac1..404ef35 100755 --- a/scripts/restore +++ b/scripts/restore @@ -121,19 +121,12 @@ ynh_restore_file --origin_path="/etc/supervisor/conf.d/$app.conf" supervisorctl reread supervisorctl update -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add uwsgi --log="/var/log/uwsgi/$app/$app.log" +yunohost service add uwsgi --log="/var/log/uwsgi/app/$app.log" yunohost service add supervisor --log="/var/log/supervisor/supervisord.log" #================================================= @@ -142,8 +135,8 @@ yunohost service add supervisor --log="/var/log/supervisor/supervisord.log" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" -ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" +ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app.log" --line_match="spawned uWSGI" +ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index d9a11a7..40d84b1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -59,7 +59,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_supervisor_action --service_name=$app --action="stop" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" +ynh_supervisor_action --service_name=$app --action="stop" --log_path="/var/log/supervisor/supervisord.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -164,6 +164,7 @@ pushd "$final_path" popd ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_package_autoremove chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -194,20 +195,12 @@ ln -sf /etc/uwsgi/apps-available/$app-caldav.ini /etc/uwsgi/apps-enabled/$app-ca #================================================= # GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add uwsgi --log="/var/log/uwsgi/$app/$app.log" +yunohost service add uwsgi --log="/var/log/uwsgi/app/$app.log" yunohost service add supervisor --log="/var/log/supervisor/supervisord.log" #================================================= @@ -216,16 +209,8 @@ yunohost service add supervisor --log="/var/log/supervisor/supervisord.log" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/$app/$app.log" -ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #--line_match="line to match" - -#================================================= -# UPGRADE FAIL2BAN -#================================================= -ynh_script_progression --message="Reconfiguring Fail2Ban..." - -# Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" +ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app.log" --line_match="spawned uWSGI" +ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log" #================================================= # RELOAD NGINX