Supervisor monitors Gearman tasks

Source: Internet
Author: User

Supervisor monitors Gearman tasks

To install a supervisor, you can directly use yum install supervisord. However, the version may be earlier. Refer to the official method:
Easy_install supervisor

Http://supervisord.org/installing.html#installing-to-a-system-with-internet-access

Add service, vim/etc/init. d/supervisord, and modify the file attributes to execute chmod 777/etc/init. d/supervisord.

#! /Bin/bash
#
# Supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <mmcgrath@RedHat.com> (based off yumupdatesd)
# Jason Koppe <jkoppe@indeed.com> adjusted to read sysconfig,
# Use supervisord tools to start/stop, conditionally wait
# For child processes to shutdown, and startup later
#
# 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:/etc/supervisord. conf
# Pidfile:/var/run/supervisord. pid
#

# Source function library
./Etc/rc. d/init. d/functions

# Source system settings
[-E/etc/sysconfig/supervisord] &./etc/sysconfig/supervisord

RETVAL = 0

Start (){
Echo "Starting supervisord :"
If [-e $ PIDFILE]; then
Echo "already started"
Return 1
Fi

# Start supervisord with options from sysconfig (stuff like-c)
/Usr/bin/supervisord $ OPTIONS

# Show initial startup status
/Usr/bin/supervisorctl $ OPTIONS status

# Only create the subsyslock if we created the PIDFILE
[-E $ PIDFILE] & touch/var/lock/subsys/supervisord
}

Stop (){
Echo-n "Stopping supervisord :"
/Usr/bin/supervisorctl $ OPTIONS shutdown
If [-n "$ WAIT_FOR_SUBPROCESSES"]; then
Echo "Waiting roughly 60 seconds for $ PIDFILE to be removed after child processes exit"
For sleep in 2 2 2 2 4 4 4 8 8 8 last; do
If [! -E $ PIDFILE]; then
Echo "Supervisord exited as expected in under $ total_sleep seconds"
Break
Else
If [[$ sleep-eq "last"]; then
Echo "Supervisord still working on shutting down. We 've waited roughly 60 seconds, we'll let it do its thing from here"
Return 1
Else
Sleep $ sleep
Total_sleep = $ ($ total_sleep + $ sleep ))
Fi

Fi
Done
Fi

# Always remove the subsys. we might have waited a while, but just remove it at this point.
Rm-f/var/lock/subsys/supervisord
}

Restart (){
Stop
Start
}

Case "$1" in
Start)
Start
RETVAL =$?
;;
Stop)
Stop
RETVAL =$?
;;
Restart | force-reload)
Restart
RETVAL =$?
;;
Reload)
/Usr/bin/supervisorctl $ OPTIONS reload
RETVAL =$?
;;
Condrestart)
[-F/var/lock/subsys/supervisord] & restart
RETVAL =$?
;;
Status)
/Usr/bin/supervisorctl $ OPTIONS status
RETVAL =$?
;;
*)
Echo $ "Usage: $0 {start | stop | status | restart | reload | force-reload | condrestart }"
Exit 1
Esac

Exit $ RETVAL

Configure echo_supervisord_conf>/etc/supervisord. conf

Join the gearman task. The following is the task pushed by Baidu cloud.

Vim/etc/supervisord. conf

[Program: APNS_PUSH]
Command =/usr/bin/php/data2/www/web/apns/worker_origin.php
Process_name = APNS_PUSH _ % (process_num) s
Numprocs = 2
Autostart = true
Autorestart = true
User = nginx
Stdout_logfile =/data2/log/push _ % (process_num) s. log
Stderr_logfile =/data2/log/push. error. log

Start gearman, start supervisord, ps-ef | grep xxx, and check whether the task has been executed.

You can also use gearman-monitor to view the gearman task status.

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.