1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00

improve log files management

This commit is contained in:
Jean-Baptiste Holcroft 2019-08-28 00:09:23 +02:00
parent 6872223e5a
commit f05f984efe
6 changed files with 22 additions and 15 deletions

View file

@ -17,8 +17,8 @@ CELERYD_OPTS="--beat"
# - %n will be replaced with the first part of the nodename.
# - %I will be replaced with the current child process index
# and is important when using the prefork pool to avoid race conditions.
CELERYD_PID_FILE="/var/run/__APP__-celery/weblate-%n.pid"
CELERYD_LOG_FILE="/var/log/__APP__-celery/celery-%n%I.log"
CELERYD_PID_FILE="/var/run/__APP__/weblate-celery-%n.pid"
CELERYD_LOG_FILE="/var/log/__APP__/weblate-celery-%n%I.log"
CELERYD_LOG_LEVEL="INFO"
CELERY_WORKER_RUNNING="1"

View file

@ -10,10 +10,9 @@ PermissionsStartOnly=true
EnvironmentFile=__FINALPATH__/celery-weblate
WorkingDirectory=__FINALPATH__/
# https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory=
RuntimeDirectory=__APP__-celery
RuntimeDirectory=__APP__
ExecStartPre=/bin/mkdir -p /var/log/__APP__-celery
ExecStartPre=/bin/chown -R __APP__ /var/log/__APP__-celery
ExecStartPre=/bin/chown -R __APP__ /var/log/__APP__
ExecStart=__FINALPATH__/venv/bin/celery multi start ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \

View file

@ -12,14 +12,13 @@ PermissionsStartOnly=true
# https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory=
RuntimeDirectory=__APP__
ExecStartPre=/bin/mkdir -p /var/log/uwsgi/app/__APP__
ExecStartPre=/bin/chown -R __APP__ /var/log/uwsgi/app/__APP__
ExecStartPre=/bin/chown -R __APP__ /var/log/__APP__
ExecStart=/usr/bin/uwsgi \
--ini /etc/uwsgi/apps-available/__APP__.ini \
--socket /var/run/__APP__/socket \
--chmod-socket=775 \
--logto /var/log/uwsgi/app/__APP__/weblate \
--logto /var/log/__APP__/weblate.log \
--processes 4

View file

@ -306,7 +306,7 @@ chown -R "$app": "$final_path/avatar-cache"
ynh_script_progression --message="Configuring log rotation..." --time --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile "/var/log/$app-celery"
ynh_use_logrotate
#=================================================
# SETUP SSOWAT
@ -334,8 +334,8 @@ fi
# ADVERTISE SERVICES IN ADMIN PANEL
#=================================================
yunohost service add "$app" --log "/var/log/uwsgi/app/$app/weblate"
yunohost service add "$app-celery" --log "/var/log/$app-celery"
yunohost service add "$app" --log "/var/log/$app/weblate.log"
yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log"
#=================================================
# Start weblate

View file

@ -108,8 +108,8 @@ systemctl enable "$app-celery"
#=================================================
# Add as a service
yunohost service add "$app" --log "/var/log/uwsgi/app/$app"
yunohost service add "$app-celery" --log "/var/log/$app-celery"
yunohost service add "$app" --log "/var/log/$app/weblate.log"
yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log"
#=================================================
# RESTORE THE CRON FILE

View file

@ -165,6 +165,15 @@ then
systemctl stop "$app-celery"
fi
# (<3.8) log cleanups
if [[ -e "/var/log/uwsgi/app/$app" ]]
then
ynh_systemd_action --service_name="$app" --action="stop"
ynh_systemd_action --service_name="$app-celery" --action="stop"
ynh_secure_remove "/var/log/uwsgi/app/$app"
ynh_secure_remove "/var/log/$app-celery"
fi
#=================================================
# CHECK THE PATH
#=================================================
@ -403,7 +412,7 @@ ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --logfile "/var/log/$app-celery" --non-append
ynh_use_logrotate
#=================================================
# GENERIC FINALIZATION