Skip to content

Commit

Permalink
logrotate + log in /var/log/usershub/usershub.log
Browse files Browse the repository at this point in the history
  • Loading branch information
bouttier committed Sep 6, 2022
1 parent 77c0f78 commit 4075251
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ CHANGELOG

* *systemd* : Ajout d’une dépendance au service ``postgresql``
* Amélioration de l’affichage des tables
* Fichiers de log :

* Les logs sont à présent écrits dans le fichier ``/var/log/usershub/usershub.log``
* L’outil ``logrotate`` est configuré pour assurer la rotation du fichier
* L’ancien fichier de log ``/var/log/usershub.log`` est intouché; vous pouvez le supprimer, ou l’archiver manuellement.

**🐛 Corrections**

Expand Down
5 changes: 5 additions & 0 deletions install_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ cd ../..
export USERSHUB_DIR=$(readlink -e "${0%/*}")

# Configuration systemd
envsubst '${USER}' < tmpfiles-usershub.conf | sudo tee /etc/tmpfiles.d/usershub.conf || exit 1
sudo systemd-tmpfiles --create /etc/tmpfiles.d/usershub.conf || exit 1
envsubst '${USER} ${USERSHUB_DIR}' < usershub.service | sudo tee /etc/systemd/system/usershub.service || exit 1
sudo systemctl daemon-reload || exit 1

# Configuration logrotate
envsubst '${USER}' < log_rotate | sudo tee /etc/logrotate.d/usershub

# Configuration apache
sudo cp usershub_apache.conf /etc/apache2/conf-available/usershub.conf || exit 1
sudo a2enmod proxy || exit 1
Expand Down
6 changes: 5 additions & 1 deletion log_rotate
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/var/log/usershub.log {
/var/log/usershub/usershub.log {
su ${USER} ${USER}
daily
rotate 8
size 100M
create
compress
postrotate
systemctl reload usershub || true
endscript
}
2 changes: 2 additions & 0 deletions tmpfiles-usershub.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
d /run/usershb 0750 ${USER} ${USER} -
d /var/log/usershub 0750 ${USER} ${USER} -
6 changes: 3 additions & 3 deletions usershub.service
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ Environment=GUNICORN_NUM_WORKERS=4
Environment=GUNICORN_HOST=127.0.0.1
Environment=GUNICORN_PORT=5001
Environment=GUNICORN_TIMEOUT=30
Environment=GUNICORN_LOG_FILE=/var/log/usershub/%N%I.log
EnvironmentFile=-${USERSHUB_DIR}/environ
ExecStart=${USERSHUB_DIR}/venv/bin/gunicorn app.app:create_app() \
--name "${GUNICORN_PROC_NAME}" --workers "${GUNICORN_NUM_WORKERS}" \
--bind "${GUNICORN_HOST}:${GUNICORN_PORT}" --timeout="${GUNICORN_TIMEOUT}"
--bind "${GUNICORN_HOST}:${GUNICORN_PORT}" --timeout="${GUNICORN_TIMEOUT}" \
--log-file "${GUNICORN_LOG_FILE}"
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutStartSec=10
TimeoutStopSec=5
PrivateTmp=true
StandardOutput=append:/var/log/usershub.log
StandardError=inherit

[Install]
WantedBy=multi-user.target

0 comments on commit 4075251

Please sign in to comment.