Created
June 12, 2019 07:07
-
-
Save Martin91/c6488fc418c87113263b783f529c197c to your computer and use it in GitHub Desktop.
supervisord XML/RPC API demo
This file contains 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
==================== Supported Methods ====================== | |
['supervisor.addProcessGroup', 'supervisor.clearAllProcessLogs', 'supervisor.clearLog', 'supervisor.clearProcessLog', 'supervisor.clearProcessLogs', 'supervisor.getAPIVersion', 'supervisor.getAllConfigInfo', 'supervisor.getAllProcessInfo', 'supervisor.getIdentification', 'supervisor.getPID', 'supervisor.getProcessInfo', 'supervisor.getState', 'supervisor.getSupervisorVersion', 'supervisor.getVersion', 'supervisor.readLog', 'supervisor.readMainLog', 'supervisor.readProcessLog', 'supervisor.readProcessStderrLog', 'supervisor.readProcessStdoutLog', 'supervisor.reloadConfig', 'supervisor.removeProcessGroup', 'supervisor.restart', 'supervisor.sendProcessStdin', 'supervisor.sendRemoteCommEvent', 'supervisor.shutdown', 'supervisor.signalAllProcesses', 'supervisor.signalProcess', 'supervisor.signalProcessGroup', 'supervisor.startAllProcesses', 'supervisor.startProcess', 'supervisor.startProcessGroup', 'supervisor.stopAllProcesses', 'supervisor.stopProcess', 'supervisor.stopProcessGroup', 'supervisor.tailProcessLog', 'supervisor.tailProcessStderrLog', 'supervisor.tailProcessStdoutLog', 'system.listMethods', 'system.methodHelp', 'system.methodSignature', 'system.multicall'] | |
==================== Process Information ===================== | |
{'now': 1560322893, 'group': 'say_hello', 'description': 'pid 56561, uptime 0:17:10', 'pid': 56561, 'stderr_logfile': '', 'stop': 0, 'statename': 'RUNNING', 'start': 1560321863, 'state': 20, 'stdout_logfile': '/somewhere/supervisor/log/daemon.log', 'logfile': '/somewhere/supervisor/log/daemon.log', 'exitstatus': 0, 'spawnerr': '', 'name': 'say_hello'} |
This file contains 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
import time | |
while True: | |
print("Hello") | |
time.sleep(3) |
This file contains 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
[unix_http_server] | |
file=/somewhere/supervisor/supervisor.api.sock | |
[inet_http_server] | |
port=9123 | |
[supervisord] | |
logfile=/somewhere/supervisor/log/daemon.log | |
logfile_maxbytes=50MB | |
logfile_backups=10 | |
loglevel=info | |
pidfile=/somewhere/supervisor/supervisor.api.pid | |
nodaemon=false | |
minfds=1024 | |
minprocs=200 | |
[rpcinterface:supervisor] | |
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | |
[supervisorctl] | |
serverurl=unix:///somewhere/supervisor/supervisor.api.sock | |
[program:say_hello] | |
command=python say_hello.py | |
directory=/somewhere/supervisor/ | |
user=martin91 | |
autorestart=false | |
redirect_stderr=true | |
stdout_logfile=/somewhere/supervisor/log/daemon.log | |
loglevel=info |
This file contains 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
# reference to http://supervisord.org/api.html | |
import xmlrpclib | |
# port 9123 conform to the configurated port in [inet_http_server] section | |
server = xmlrpclib.Server("http://127.0.0.1:9123/RPC2") # a http port is required | |
methods = server.system.listMethods() | |
print "==================== Supported Methods ======================" | |
print methods | |
print "==================== Process Information =====================" | |
print server.supervisor.getProcessInfo('say_hello') |
This file contains 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
supervisord -c supervisor.ini | |
python supervisor_api_consumer.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment