Last active
December 11, 2015 06:58
-
-
Save alejandrobernardis/4563050 to your computer and use it in GitHub Desktop.
Supervisor // Daemon // CentOS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [include] | |
| files = /a/path/*.supervisor | |
| [supervisord] | |
| directory = /a/path | |
| pidfile = /a/path/supervisord.pid | |
| logfile = /a/path/supervisord.log | |
| logfile_maxbytes = 50MB | |
| logfile_backups = 10 | |
| childlogdir = /a/path/logs | |
| [supervisorctl] | |
| serverurl = unix:///a/path/supervisord.sock | |
| [unix_http_server] | |
| file = /a/path/supervisord.sock | |
| [rpcinterface:supervisor] | |
| supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # /etc/rc.d/init.d/supervisord | |
| # | |
| # Supervisor is a client/server system that | |
| # allows its users to monitor and control a | |
| # number of processes on UNIX-like operating | |
| # systems. | |
| # | |
| # chkconfig: 345 83 04 | |
| # | |
| # description: supervisor is a process control utility. It has a web based | |
| # xmlrpc interface as well as a few other nifty features. | |
| # processname: supervisord | |
| # config: /a/path/supervisord.conf | |
| # pidfile: /a/path/supervisord.pid | |
| # local cfg | |
| DOMAIN='domain.com' | |
| SUPERVISOR_DIR=/a/path | |
| # service cfg | |
| PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
| NAME=supervisord | |
| DAEMON=/usr/local/bin/supervisord | |
| DAEMON_ARGS="-c /a/path/supervisord.conf -d /a/path" | |
| DAEMON_CTL=/usr/local/bin/supervisorctl | |
| CONFIGFILE=/a/path/supervisord.conf | |
| PIDFILE=/a/path/supervisord.pid | |
| SOCKFILE=/a/path/supervisord.sock | |
| LOCKFILE=/a/path/supervisord.lock | |
| RETVAL=0 | |
| # functions | |
| . /etc/rc.d/init.d/functions | |
| # actions | |
| do_start() { | |
| [ ! -e $PIDFILE ] || exit 1 | |
| [ -x $DAEMON ] || exit 5 | |
| echo -n $"$NAME ... Starting " | |
| daemon --pidfile=$PIDFILE $NAME $DAEMON_ARGS | |
| RETVAL=$? | |
| echo | |
| $DAEMON_CTL -c $CONFIGFILE status | |
| [ $RETVAL = 0 ] && touch $LOCKFILE | |
| return $RETVAL | |
| } | |
| do_stop() { | |
| [ -e $PIDFILE ] || exit 1 | |
| [ -x $DAEMON_CTL ] || exit 5 | |
| $DAEMON_CTL -c $CONFIGFILE stop all | |
| echo -n $"$NAME ... Stopping " | |
| killproc -p $PIDFILE $NAME | |
| RETVAL=$? | |
| echo | |
| [ $RETVAL = 0 ] && rm -f $PIDFILE $SOCKFILE $LOCKFILE | |
| return $RETVAL | |
| } | |
| do_status() { | |
| [ -e $PIDFILE ] || exit 1 | |
| [ -x $DAEMON_CTL ] || exit 5 | |
| echo $"$NAME ... Get status " | |
| $DAEMON_CTL -c $CONFIGFILE status | |
| echo | |
| } | |
| do_restart() { | |
| [ -e $PIDFILE ] || exit 1 | |
| [ -x $DAEMON_CTL ] || exit 5 | |
| echo $"$NAME ... Restarting " | |
| $DAEMON_CTL -c $CONFIGFILE restart all | |
| echo | |
| } | |
| rh_status() { | |
| status -p $PIDFILE $NAME | |
| } | |
| rh_status_q() { | |
| rh_status >/dev/null 2>&1 | |
| } | |
| case "$1" in | |
| start) | |
| rh_status_q && exit 0 | |
| do_start | |
| ;; | |
| stop) | |
| rh_status_q || exit 0 | |
| do_stop | |
| ;; | |
| reload) | |
| rh_status_q || exit 0 | |
| do_stop | |
| do_start | |
| ;; | |
| status) | |
| rh_status_q || exit 0 | |
| do_status | |
| ;; | |
| restart) | |
| rh_status_q || exit 0 | |
| do_restart | |
| ;; | |
| *) | |
| echo $"Usage: $NAME {start|stop|reload|status|restart}" | |
| exit 1 | |
| esac | |
| exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment