Supervisor 2019(1)CentOS 7

fhxyxzw 2019-08-19

Supervisor2019(1)CentOS7

InstallthecurrentlatestversiononCentOS7

>sudoyuminstallsupervisor

Afterinstallation,checkthedefaultconfiguration

>echo_supervisord_conf

;Samplesupervisorconfigfile.

;

;Formoreinformationontheconfigfile,pleasesee:

;http://supervisord.org/configuration.html

;

;Notes:

;-Shellexpansion("~"or"$HOME")isnotsupported.Environment

;variablescanbeexpandedusingthissyntax:"%(ENV_HOME)s".

;-Commentsmusthavealeadingspace:"a=b;comment"not"a=b;comment".

[unix_http_server]

file=/tmp/supervisor.sock;(thepathtothesocketfile)

;chmod=0700;socketfilemode(default0700)

;chown=nobody:nogroup;socketfileuid:gidowner

;username=user;(defaultisnousername(openserver))

;password=123;(defaultisnopassword(openserver))

;[inet_http_server];inet(TCP)serverdisabledbydefault

;port=127.0.0.1:9001;(ip_address:portspecifier,*:portforalliface)

;username=user;(defaultisnousername(openserver))

;password=123;(defaultisnopassword(openserver))

[supervisord]

logfile=/tmp/supervisord.log;(mainlogfile;default$CWD/supervisord.log)

logfile_maxbytes=50MB;(maxmainlogfilebytesb4rotation;default50MB)

logfile_backups=10;(numofmainlogfilerotationbackups;default10)

loglevel=info;(loglevel;defaultinfo;others:debug,warn,trace)

pidfile=/tmp/supervisord.pid;(supervisordpidfile;defaultsupervisord.pid)

nodaemon=false;(startinforegroundiftrue;defaultfalse)

minfds=1024;(min.availstartupfiledescriptors;default1024)

minprocs=200;(min.availprocessdescriptors;default200)

;umask=022;(processfilecreationumask;default022)

;user=chrism;(defaultiscurrentuser,requiredifroot)

;identifier=supervisor;(supervisordidentifier,defaultis'supervisor')

;directory=/tmp;(defaultisnottocdduringstart)

;nocleanup=true;(don'tcleanuptempfilesatstart;defaultfalse)

;childlogdir=/tmp;('AUTO'childlogdir,default$TEMP)

;environment=KEY="value";(keyvaluepairstoaddtoenvironment)

;strip_ansi=false;(stripansiescapecodesinlogs;def.false)

;thebelowsectionmustremainintheconfigfileforRPC

;(supervisorctl/webinterface)towork,additionalinterfacesmaybe

;addedbydefiningtheminseparaterpcinterface:sections

[rpcinterface:supervisor]

supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]

serverurl=unix:///tmp/supervisor.sock;useaunix://URLforaunixsocket

;serverurl=http://127.0.0.1:9001;useanhttp://urltospecifyaninetsocket

;username=chris;shouldbesameashttp_usernameifset

;password=123;shouldbesameashttp_passwordifset

;prompt=mysupervisor;cmdlineprompt(default"supervisor")

;history_file=~/.sc_history;usereadlinehistoryifavailable

;Thebelowsampleprogramsectionshowsallpossibleprogramsubsectionvalues,

;createoneormore'real'program:sectionstobeabletocontrolthemunder

;supervisor.

;[program:theprogramname]

;command=/bin/cat;theprogram(relativeusesPATH,cantakeargs)

;process_name=%(program_name)s;process_nameexpr(default%(program_name)s)

;numprocs=1;numberofprocessescopiestostart(def1)

;directory=/tmp;directorytocwdtobeforeexec(defnocwd)

;umask=022;umaskforprocess(defaultNone)

;priority=999;therelativestartpriority(default999)

;autostart=true;startatsupervisordstart(default:true)

;autorestart=unexpected;whether/whentorestart(default:unexpected)

;startsecs=1;numberofsecsprogmuststayrunning(def.1)

;startretries=3;max#ofserialstartfailures(default3)

;exitcodes=0,2;'expected'exitcodesforprocess(default0,2)

;stopsignal=QUIT;signalusedtokillprocess(defaultTERM)

;stopwaitsecs=10;maxnumsecstowaitb4SIGKILL(default10)

;stopasgroup=false;sendstopsignaltotheUNIXprocessgroup(defaultfalse)

;killasgroup=false;SIGKILLtheUNIXprocessgroup(deffalse)

;user=chrism;setuidtothisUNIXaccounttoruntheprogram

;redirect_stderr=true;redirectprocstderrtostdout(defaultfalse)

;stdout_logfile=/a/path;stdoutlogpath,NONEfornone;defaultAUTO

;stdout_logfile_maxbytes=1MB;max#logfilebytesb4rotation(default50MB)

;stdout_logfile_backups=10;#ofstdoutlogfilebackups(default10)

;stdout_capture_maxbytes=1MB;numberofbytesin'capturemode'(default0)

;stdout_events_enabled=false;emiteventsonstdoutwrites(defaultfalse)

;stderr_logfile=/a/path;stderrlogpath,NONEfornone;defaultAUTO

;stderr_logfile_maxbytes=1MB;max#logfilebytesb4rotation(default50MB)

;stderr_logfile_backups=10;#ofstderrlogfilebackups(default10)

;stderr_capture_maxbytes=1MB;numberofbytesin'capturemode'(default0)

;stderr_events_enabled=false;emiteventsonstderrwrites(defaultfalse)

;environment=A="1",B="2";processenvironmentadditions(defnoadds)

;serverurl=AUTO;overrideserverurlcomputation(childutils)

;Thebelowsampleeventlistenersectionshowsallpossible

;eventlistenersubsectionvalues,createoneormore'real'

;eventlistener:sectionstobeabletohandleeventnotifications

;sentbysupervisor.

;[eventlistener:theeventlistenername]

;command=/bin/eventlistener;theprogram(relativeusesPATH,cantakeargs)

;process_name=%(program_name)s;process_nameexpr(default%(program_name)s)

;numprocs=1;numberofprocessescopiestostart(def1)

;events=EVENT;eventnotif.typestosubscribeto(req'd)

;buffer_size=10;eventbufferqueuesize(default10)

;directory=/tmp;directorytocwdtobeforeexec(defnocwd)

;umask=022;umaskforprocess(defaultNone)

;priority=-1;therelativestartpriority(default-1)

;autostart=true;startatsupervisordstart(default:true)

;autorestart=unexpected;whether/whentorestart(default:unexpected)

;startsecs=1;numberofsecsprogmuststayrunning(def.1)

;startretries=3;max#ofserialstartfailures(default3)

;exitcodes=0,2;'expected'exitcodesforprocess(default0,2)

;stopsignal=QUIT;signalusedtokillprocess(defaultTERM)

;stopwaitsecs=10;maxnumsecstowaitb4SIGKILL(default10)

;stopasgroup=false;sendstopsignaltotheUNIXprocessgroup(defaultfalse)

;killasgroup=false;SIGKILLtheUNIXprocessgroup(deffalse)

;user=chrism;setuidtothisUNIXaccounttoruntheprogram

;redirect_stderr=true;redirectprocstderrtostdout(defaultfalse)

;stdout_logfile=/a/path;stdoutlogpath,NONEfornone;defaultAUTO

;stdout_logfile_maxbytes=1MB;max#logfilebytesb4rotation(default50MB)

;stdout_logfile_backups=10;#ofstdoutlogfilebackups(default10)

;stdout_events_enabled=false;emiteventsonstdoutwrites(defaultfalse)

;stderr_logfile=/a/path;stderrlogpath,NONEfornone;defaultAUTO

;stderr_logfile_maxbytes=1MB;max#logfilebytesb4rotation(default50MB)

;stderr_logfile_backups;#ofstderrlogfilebackups(default10)

;stderr_events_enabled=false;emiteventsonstderrwrites(defaultfalse)

;environment=A="1",B="2";processenvironmentadditions

;serverurl=AUTO;overrideserverurlcomputation(childutils)

;Thebelowsamplegroupsectionshowsallpossiblegroupvalues,

;createoneormore'real'group:sectionstocreate"heterogeneous"

;processgroups.

;[group:thegroupname]

;programs=progname1,progname2;eachrefersto'x'in[program:x]definitions

;priority=999;therelativestartpriority(default999)

;The[include]sectioncanjustcontainthe"files"setting.This

;settingcanlistmultiplefiles(separatedbywhitespaceor

;newlines).Itcanalsocontainwildcards.Thefilenamesare

;interpretedasrelativetothisfile.Includedfiles*cannot*

;includefilesthemselves.

;[include]

;files=relative/directory/*.ini

Usually,weshouldnotchangethedefaultconfiguration,weshoulduseotherfile

>vi/etc/supervisord.conf

[unix_http_server]

file=/var/run/supervisor/supervisor.sock;(thepathtothesocketfile)

[inet_http_server];inet(TCP)serverdisabledbydefault

port=0.0.0.0:9001

username=sillycat

password=123456

[supervisord]

logfile=/var/log/supervisor/supervisord.log;(mainlogfile;default$CWD/supervisord.log)

logfile_maxbytes=50MB;(maxmainlogfilebytesb4rotation;default50MB)

logfile_backups=10;(numofmainlogfilerotationbackups;default10)

loglevel=info;(loglevel;defaultinfo;others:debug,warn,trace)

pidfile=/var/run/supervisord.pid;(supervisordpidfile;defaultsupervisord.pid)

nodaemon=false;(startinforegroundiftrue;defaultfalse)

minfds=65536;(min.availstartupfiledescriptors;default1024)

minprocs=32769;(min.availprocessdescriptors;default200)

[rpcinterface:supervisor]

supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]

serverurl=unix:///var/run/supervisor/supervisor.sock;useaunix://URLforaunixsocket

ExampleformonitorElasticsearch

[program:elasticsearch]

user=elastic

command=/home/elastic/tool/elasticsearch-7.2.1/bin/elasticsearch

autostart=true

autorestart=true

environment=ES_HEAP_SIZE=2g

stdout_logfile=/var/log/supervisor/elasticsearch.out.log

stderr_logfile=/var/log/supervisor/elasticsearch.err.log

Exampleformonitorkibana

[program:kibana]

user=elastic

command=/home/elastic/tool/kibana-7.2.1/bin/kibana

autostart=true

autorestart=true

stdout_logfile=/var/log/supervisor/kibana.out.log

stderr_logfile=/var/log/supervisor/kibana.err.log

Iincreatethedefaultsettings

minfds=65536;(min.availstartupfiledescriptors;default1024)

minprocs=32769;(min.availprocessdescriptors;default200)

Enabletheservice

>sudosystemctlenablesupervisord

Starttheservice

>sudosystemctlstartsupervisord

Checkstatus

>sudosystemctlenablesupervisord

WecaneasilyvisittheUI

http://centos-dev1:9001/

Accordingtothedocsfromherehttps://www.jianshu.com/p/bf2b3f4dec73,wecandomoresettingsandconfigurations.

[include]

files=supervisord.d/*.ini

Wecanputtheprogramsconfigurationseparatelyinthesupervisord.d/*.ini

References:

http://supervisord.org/

https://www.jianshu.com/p/bf2b3f4dec73

相关推荐