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