From 3a6cf6aee814a81dc5ebede7f206a65a7a3cd80f Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Thu, 25 Jun 2015 21:34:03 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20d'un=20service=20intranet2=20av?= =?UTF-8?q?ec=20systemd=20dans=20le=20groupe=20intranet2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bundler/intranet2-service.xml | 5 +++ Metadata/groups.xml | 5 +++ Python/etc/systemd/system/intranet2.service | 43 +++++++++++++++++++++ Python/etc/systemd/system/intranet2.socket | 20 ++++++++++ 4 files changed, 73 insertions(+) create mode 100644 Bundler/intranet2-service.xml create mode 100644 Python/etc/systemd/system/intranet2.service create mode 100644 Python/etc/systemd/system/intranet2.socket diff --git a/Bundler/intranet2-service.xml b/Bundler/intranet2-service.xml new file mode 100644 index 0000000..3d9fd7e --- /dev/null +++ b/Bundler/intranet2-service.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Metadata/groups.xml b/Metadata/groups.xml index f74f038..c5add1d 100644 --- a/Metadata/groups.xml +++ b/Metadata/groups.xml @@ -221,6 +221,7 @@ + @@ -1586,6 +1587,10 @@ + + + + diff --git a/Python/etc/systemd/system/intranet2.service b/Python/etc/systemd/system/intranet2.service new file mode 100644 index 0000000..cdaf243 --- /dev/null +++ b/Python/etc/systemd/system/intranet2.service @@ -0,0 +1,43 @@ +# -*- coding: utf-8; mode: python -*- + +info["owner"] = "root" +info["group"] = "root" +info["mode"] = 0644 + +out("""#Fichier géré par Bcfg2 +# Fichier systemd pour faire fonctionner l'intranet avec gunicorn +# Ce service est configuré pour : +# ---> Ouvrir, si besoin, la socket intranet2 avant de démarrer +# ---> Démarrer, si besoin, nginx avant de démarrer +# ---> Démarrer, si besoin, postgresql avant de démarrer +# ---> Se lancer en tant que daemon +[Unit] +Description=Crans Intranet 2 +Requires=nginx.service +Requires=postgresql.service +Requires=intranet2.socket +After=nginx.service +After=postgresql.service +After=network-online.target + +[Service] +Type=forking +User=root +Group=root +PIDFile=/run/gunicorn/intranet2.pid""") +if has('intranet2-dev'): + out("""WorkingDirectory=/localhome/django/intranet-dev/""") +if has('intranet2-server'): + out("""WorkingDirectory=/usr/local/intranet/""") +out("""ExecStart=/usr/bin/gunicorn wsgi:application --pid=/run/gunicorn/intranet2.pid --name www-data --user www-data --group www-data --daemon --log-file /var/log/gunicorn/intranet2.log --log-level=info --bind=unix:///tmp/gunicorn-intranet.sock --workers=1 +ExecReload=/bin/kill -s HUP $MAINPID +ExecStop=/bin/kill -s TERM $MAINPID +Restart=on-failure +RestartSec=65 +StartLimitInterval=60 +StartLimitBurst=2 + +[Install] +WantedBy=multi-user.target +Also=intranet2.socket""") + diff --git a/Python/etc/systemd/system/intranet2.socket b/Python/etc/systemd/system/intranet2.socket new file mode 100644 index 0000000..2314b05 --- /dev/null +++ b/Python/etc/systemd/system/intranet2.socket @@ -0,0 +1,20 @@ +# -*- coding: utf-8; mode: python -*- + +info["owner"] = "root" +info["group"] = "root" +info["mode"] = 0644 + +out("""# Fichier géré par Bcfg2 +# Fichier de configuration systemd pour la socket de l'intranet2 +# Ce service est configuré pour: +# ----> Ouvrir une socket UNIX +# ----> Permettre à intranet2.service d'écouter sur la socket +[Unit] +Description=Socket Intranet 2 + +[Socket] +ListenStream=/tmp/gunicorn-intranet.sock + +[Install] +WantedBy=sockets.target""") +