From b3ad23fcc66bf6a7302319a118bb1127c2653c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Tue, 5 Dec 2017 23:07:13 +0100 Subject: [PATCH] Nginx: fix fcgi Munin graphs fixes https://forge.evolix.org/issues/2371 --- nginx/files/init.d/spawn-fcgi-munin-graph | 130 ------------------ .../systemd/spawn-fcgi-munin-graph.service | 10 ++ nginx/tasks/munin_vhost.yml | 16 +-- 3 files changed, 16 insertions(+), 140 deletions(-) delete mode 100644 nginx/files/init.d/spawn-fcgi-munin-graph create mode 100644 nginx/files/systemd/spawn-fcgi-munin-graph.service diff --git a/nginx/files/init.d/spawn-fcgi-munin-graph b/nginx/files/init.d/spawn-fcgi-munin-graph deleted file mode 100644 index 7d5d6055..00000000 --- a/nginx/files/init.d/spawn-fcgi-munin-graph +++ /dev/null @@ -1,130 +0,0 @@ -#! /bin/sh - -### BEGIN INIT INFO -# Provides: spawn-fcgi-munin-graph -# Required-Start: $all -# Required-Stop: $all -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Description: starts FastCGI for Munin-Graph -### END INIT INFO -# -------------------------------------------------------------- -# Munin-CGI-Graph Spawn-FCGI Startscript by Julien Schmidt -# eMail: munin-trac at julienschmidt.com -# www: http://www.julienschmidt.com -# -------------------------------------------------------------- -# Install: -# 1. Copy this file to /etc/init.d -# 2. Edit the variables below -# 3. run "update-rc.d spawn-fcgi-munin-graph defaults" -# -------------------------------------------------------------- -# Special thanks for their help to: -# Frantisek Princ -# J�r�me Warnier -# -------------------------------------------------------------- -# Last Update: 14. February 2013 -# -# Please change the following variables: - -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -NAME=spawn-fcgi-munin-graph -PID_FILE=/var/run/munin/$NAME.pid -SOCK_FILE=/var/run/munin/$NAME.sock -SOCK_USER=www-data -FCGI_USER=munin -FCGI_GROUP=munin -FCGI_WORKERS=2 -DAEMON=/usr/bin/spawn-fcgi -DAEMON_OPTS="-s $SOCK_FILE -F $FCGI_WORKERS -U $SOCK_USER -u $FCGI_USER -g $FCGI_GROUP -P $PID_FILE -- /usr/lib/munin/cgi/munin-cgi-graph" - -# -------------------------------------------------------------- -# No edits necessary beyond this line -# -------------------------------------------------------------- - -if [ ! -x $DAEMON ]; then - echo "File not found or is not executable: $DAEMON!" - exit 0 -fi - -status() { - if [ ! -r $PID_FILE ]; then - return 1 - fi - - for FCGI_PID in `cat $PID_FILE`; do - if [ -z "${FCGI_PID}" ]; then - return 1 - fi - - FCGI_RUNNING=`ps -p ${FCGI_PID} | grep ${FCGI_PID}` - if [ -z "${FCGI_RUNNING}" ]; then - return 1 - fi - done; - - return 0 -} - -start() { - if status; then - echo "FCGI is already running!" - exit 1 - else - $DAEMON $DAEMON_OPTS - fi -} - -stop () { - if ! status; then - echo "No PID-file at $PID_FILE found or PID not valid. Maybe not running" - exit 1 - fi - - # Kill processes - for PID_RUNNING in `cat $PID_FILE`; do - kill -9 $PID_RUNNING - done - - # Remove PID-file - rm -f $PID_FILE - - # Remove Sock-File - rm -f $SOCK_FILE -} - -case "$1" in - start) - echo "Starting $NAME: " - start - echo "... DONE" - ;; - - stop) - echo "Stopping $NAME: " - stop - echo "... DONE" - ;; - - force-reload|restart) - echo "Stopping $NAME: " - stop - echo "Starting $NAME: " - start - echo "... DONE" - ;; - - status) - if status; then - echo "FCGI is RUNNING" - else - echo "FCGI is NOT RUNNING" - fi - ;; - - *) - echo "Usage: $0 {start|stop|force-reload|restart|status}" - exit 1 - ;; -esac - -exit 0 diff --git a/nginx/files/systemd/spawn-fcgi-munin-graph.service b/nginx/files/systemd/spawn-fcgi-munin-graph.service new file mode 100644 index 00000000..103d25c5 --- /dev/null +++ b/nginx/files/systemd/spawn-fcgi-munin-graph.service @@ -0,0 +1,10 @@ +[Unit] +Description=Munin zoom for nginx. +After=network.target + +[Service] +ExecStart=/usr/bin/spawn-fcgi -s /var/run/munin/spawn-fcgi-munin-graph.sock -U www-data -u munin -g munin /usr/lib/munin/cgi/munin-cgi-graph +Type=forking + +[Install] +WantedBy=default.target diff --git a/nginx/tasks/munin_vhost.yml b/nginx/tasks/munin_vhost.yml index d45353c0..3ff20c09 100644 --- a/nginx/tasks/munin_vhost.yml +++ b/nginx/tasks/munin_vhost.yml @@ -12,6 +12,7 @@ state: present with_items: - liblwp-useragent-determined-perl + - libcgi-fast-perl - spawn-fcgi - name: Adjust rights for munin-cgi @@ -24,17 +25,12 @@ - name: Install Init script for Munin-fcgi copy: - src: init.d/spawn-fcgi-munin-graph - dest: /etc/init.d/ - mode: "0755" - register: install_spawn_fcgi_munin_graph + src: systemd/spawn-fcgi-munin-graph.service + dest: /etc/systemd/system/spawn-fcgi-munin-graph.service -- name: Reload systemd - command: systemctl daemon-reload - when: install_spawn_fcgi_munin_graph | changed - -- name: Ensure that Munin-fcgi is started/stopped correctly - service: +- name: Enable and start Munin-fcgi + systemd: name: spawn-fcgi-munin-graph + daemon_reload: yes enabled: yes state: started