際際滷

際際滷Share a Scribd company logo
Installation

Linux?
 As easy as 'pip install supervisor'

Windows?
 No not possible

OtherInstallationmethods
Kick Start? Yes!

Seewhatoptionsexists
<echo_supervisord_conf>

Createyourconfigfilelikethis

Whatarewewaitingfor???
<supervisord足c/etc/supervisor/supervisord.conf>
Alright. So what does it do.

Notareplacementforupstart/systemd/init

Complimentsservicemanager.How?

Service manager start your process on boot, but do not monitor crash

Does not depend of pid files

Allows non root users to start/stop/restart user level services

Ordering of service start up

Daemonizes your script and logs its <stdout> and <stderr>

Provides hooks you could exploit in your code 

Readityourselves
Whats it got?

Theserver<supervisord>

Theclient<supervisorctl>

Whatelse?

'XML-RPC API'

'Web UI'

'Event management'
Lets Process!

Yourprocessneednotbeadaemon

Couldbeassimleasprintingafewlines

Yes just print. Supervisord will log it for you.
importos
importtime
sin,sout,serr=os.popen3('ps足ef')
while1:
printsout.read()
printserr.read()
time.sleep(10)

Tellsupervisordtomanageyourprocess
[program:process_check]
command=python /home/akandavelu/spyder/supervisord_learning/process_check.py
Start ! Stop ! Restart !

Relax!supervisorctlwilldoitforyou.
supervisorctl -u user -p 123 status process_check
supervisorctl -u user -p 123 restart process_check
supervisorctl -u user -p 123 stop process_check
supervisorctl -u user -p 123 tail process_check
That is not all

Processwillbestartedintheorderinwhichtheyare
specified

Morecontrolonprocessisavailablethroughevents

Processcanbestarted/stoppedingroups

Completelistofprocessoptions
Lets do it on Web

EnableXMLRPCandHTTPinsupervisorconfigfile
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
chmod=0700 ; socket file mode (default 0700)
chown=nobody:nogroup ; socket file uid:gid owner
username=user ; (default is no username (open server))
password=123 ; (default is no password (open server))
[inet_http_server] ; inet (TCP) server disabled by default
port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)
username=user ; (default is no username (open server))
password=123 ; (default is no password (open server))
Do it from another program

TheXMLRPCapiallowsforinteractiontosupervisord
programatically
import xmlrpclib
server = xmlrpclib.Server('http://localhost:9001/RPC2')
server.system.listMethods()
server.supervisor.getAllProcessInfo()
Child Process Logging

Bydefaultstdoutandstderrofchildprocessare
storedin/tmp

Canbechangedusing'childlogdir'paramin
configfile

Optionsforloggingstdoutandstderrtoseparate
files,alongwithmaxfilesizeareavailable.
Events ??

Todetectprocesscrashandrespondaccordingly

Generatecrashreportandnotifyadminviamail

Howdoesithappen?
 User specifies event listeners in supervisor config file
 User specifies what event types the listener should be sent
 Supervisord talks to the listener via its stdin and stdout in
pre defined format
Create a listener

Configurealistenerthatsubscribesforcrashevent
fromaprocess
[eventlistener:check_process_crash]
command=python /home/akandavelu/spyder/supervisord_learning/check_process_crash.py
events=PROCESS_STATE_EXITED

Startedlistenerwouldbeinvokedeverytimeany
processexits

Listenerscouldaslobeconfiguredtorunataspecified
frequency
More ?

Writinglistenersiseasiersinpythonwith
'supervisor.childutils'

SupervisordXMLRPIcanbecustomized

Configuresupervisordtosendmailsonevents

Automateyoubuild

Thirdpartyapplicationsusingsupervisord.
More ??

Supervisordisopensourcesoyoucancontribute

Itsextensible,soyoucanaddmorefeaturesonthe
fly
Thank You
Ageeleshwar K

More Related Content

Supervisord, The Process Manager