easy_install supervisor2. Generate config file
echo_supervisord_conf > /etc/supervisord.conf3. Prepare for application conf files
mkdir /etc/supervisord.conf.dEdit /etc/supervisord.conf
vi /etc/supervisord.confAdd line
[include]4. Create file /etc/init.d/supervisord
files = /etc/supervisord.conf.d/*.conf
vi /etc/init.d/supervisordContent:
#! /bin/bash -eChange permission and update service
SUPERVISORD=/usr/local/bin/supervisord
PIDFILE=/tmp/supervisord.pid
OPTS="-c /etc/supervisord.conf"
test -x $SUPERVISORD || exit 0
. /lib/lsb/init-functions
export PATH="${PATH:+$PATH:}/usr/local/bin:/usr/sbin:/sbin"
case "$1" in
start)
log_begin_msg "Starting Supervisor daemon manager..."
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $SUPERVISORD -- $OPTS || log_end_msg 1
log_end_msg 0
;;
stop)
log_begin_msg "Stopping Supervisor daemon manager..."
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE || log_end_msg 1
log_end_msg 0
;;
restart|reload|force-reload)
log_begin_msg "Restarting Supervisor daemon manager..."
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE
start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec $SUPERVISORD -- $OPTS || log_end_msg 1
log_end_msg 0
;;
*)
log_success_msg "Usage: /etc/init.d/supervisor
{start|stop|reload|force-reload|restart}"
exit 1
esac
exit 0
chmod +x /etc/init.d/supervisord
update-rc.d supervisord defaults
5. Add your application conf files into folder /etc/supervisord.conf.d
For example
vi /etc/supervisord.conf.d/mytest.confContent
[program:sqlparse]6. Start/stop/restart supervisor daemon service
directory = /var/www/python
command = /bin/env python test.py
service supervisord start/stop/restartRepeat step 5, 6 to add more application you want.
7. Then, you can use supervisorctl to manage your tasks.
supervisorctl
Issue:
If you found this error when you restart service
* Starting Supervisor daemon manager...Try this
Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.
For help, use /usr/bin/supervisord -h
...fail!
sudo unlink /tmp/supervisor.sock
No comments:
Post a Comment