From bb0e57dbc6ad65d2c6be54313bd95ac1ded1b781 Mon Sep 17 00:00:00 2001 From: Antoine Van Elstraete Date: Wed, 11 Mar 2026 20:55:38 +0100 Subject: [PATCH] =?UTF-8?q?docs:=20ajout=20service=20systemd=20et=20instru?= =?UTF-8?q?ctions=20de=20d=C3=A9ploiement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - tableau-de-bord-pro.service : service Gunicorn pour www-data - README : section production avec systemctl edit --full Co-Authored-By: Claude Sonnet 4.6 --- README.md | 23 +++++++++++++++++++++-- tableau-de-bord-pro.service | 17 +++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tableau-de-bord-pro.service diff --git a/README.md b/README.md index 4f8342d..b4d93cc 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,29 @@ python -m venv .venv L'application est accessible sur `http://localhost:5000`. -### Production (Gunicorn) +### Production (systemd + Gunicorn) + +Déploiement dans `/var/www/tableau-de-bord-pro/`, service géré par systemd. ```bash -SECRET_KEY= ./start.sh +# Copier l'application +sudo rsync -a --exclude='.venv' --exclude='instance' . /var/www/tableau-de-bord-pro/ +cd /var/www/tableau-de-bord-pro +sudo python -m venv .venv +sudo .venv/bin/pip install -r requirements.txt +sudo chown -R www-data:www-data /var/www/tableau-de-bord-pro + +# Installer le service +sudo cp tableau-de-bord-pro.service /etc/systemd/system/ + +# Configurer (notamment SECRET_KEY) +sudo systemctl edit --full tableau-de-bord-pro + +# Activer et démarrer +sudo systemctl enable --now tableau-de-bord-pro + +# Vérifier +sudo systemctl status tableau-de-bord-pro ``` ### Configuration diff --git a/tableau-de-bord-pro.service b/tableau-de-bord-pro.service new file mode 100644 index 0000000..cf7a2a8 --- /dev/null +++ b/tableau-de-bord-pro.service @@ -0,0 +1,17 @@ +[Unit] +Description=Tableau de bord pro (Gunicorn) +After=network.target + +[Service] +User=www-data +Group=www-data +WorkingDirectory=/var/www/tableau-de-bord-pro +Environment=SECRET_KEY=changeme-replace-with-a-strong-secret +ExecStart=/var/www/tableau-de-bord-pro/.venv/bin/gunicorn \ + -c /var/www/tableau-de-bord-pro/gunicorn.conf.py \ + "app:create_app()" +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target