Création d'un service intranet2 avec systemd dans le groupe intranet2

This commit is contained in:
Gabriel Detraz 2015-06-25 21:34:03 +02:00
parent 1ec5cef1e6
commit 3a6cf6aee8
4 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,5 @@
<Bundle name="intranet2-service">
<Python name="/etc/systemd/system/intranet2.service"/>
<Python name="/etc/systemd/system/intranet2.socket"/>
</Bundle>

View file

@ -221,6 +221,7 @@
<Group name="non-free"/> <Group name="non-free"/>
<Group name="db-replicat-test"/> <Group name="db-replicat-test"/>
<Group name="secrets-acl" /> <Group name="secrets-acl" />
<Group name="intranet2-dev" />
<Bundle name="fortunes"/> <Bundle name="fortunes"/>
</Group> </Group>
@ -1586,6 +1587,10 @@
<Bundle name="gammu"/> <Bundle name="gammu"/>
</Group> </Group>
<Group name="intranet2-dev">
<Bundle name="intranet2-service"/>
</Group>
<!-- +====================+ --> <!-- +====================+ -->
<!-- | Groupes dynamiques | --> <!-- | Groupes dynamiques | -->

View file

@ -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""")

View file

@ -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""")