绕过主管讨厌的回调堆栈,让它快速!
supervisor-quick的Python项目详细描述
绕过主管讨厌的回调堆栈,让它快速
用法
$ pip install supervisor-quick
并将以下配置添加到supervisord.conf中
[ctlplugin:quick]supervisor.ctl_factory=supervisor_quick:make_quick_controllerplugin
然后启动supervisortl并使用quickstart、quickstop和 快速重新启动以启动/停止/重新启动进程
> quickstart app:0 > quickstart app: > quickstart ap* > quickstart all > quickstop app:1 > quickstop app: > quickstop ap* > quickstop all > quickrestart app:2 > quickrestart app: > quickrestart ap* > quickrestart all
它会影响到supervisortl,因此您不必重新启动整个 监督工作
为什么
我写这个插件是因为主管太慢了 在我们的prod服务器中启动/停止/重新启动app server。
我检查了源代码,发现是因为 讨厌的回调堆栈,这是来自源代码的引用 主管/rpcinterface.py:
# XXX the above implementation has a weakness inasmuch as the # first call into each individual process callback will always # return NOT_DONE_YET, so they need to be called twice. The # symptom of this is that calling this method causes the # client to block for much longer than it actually requires to # kill all of the running processes. After the first call to # the killit callback, the process is actually dead, but the # above killall method processes the callbacks one at a time # during the select loop, which, because there is no output # from child processes after e.g. stopAllProcesses is called, # is not busy, so hits the timeout for each callback. I # attempted to make this better, but the only way to make it # better assumes totally synchronous reaping of child # processes, which requires infrastructure changes to # supervisord that are scary at the moment as it could take a # while to pin down all of the platform differences and might # require a C extension to the Python signal module to allow # the setting of ignore flags to signals.
这个插件将执行一个绕过 所有的回拨检查,让它闪电般的快。
它还支持通配符并发执行,使其保持快速 不管进程数量。(此功能的灵感来自 supervisor-wildcards)
示例
numprocs设置为32的应用服务器的示例时间演示 主管可以使用quick命令。
$ supervisorctl status app:0 STOPPED app:1 STOPPED app:10 STOPPED ...... app:7 STOPPED app:8 STOPPED app:9 STOPPED $ time supervisorctl start app: 24: started 25: started 26: started ...... 18: started 31: started 30: started supervisorctl start app: 0.06s user 0.02s system 0% cpu 48.442 total $ time supervisorctl stop app: 24: stopped 25: stopped 26: stopped ...... 18: stopped 31: stopped 30: stopped supervisorctl stop app: 0.06s user 0.03s system 0% cpu 36.278 total $ time supervisorctl quickstart app: app:25: started app:24: started app:27: started ...... app:1: started app:8: started app:9: started supervisorctl quickstart app: 0.09s user 0.03s system 19% cpu 0.618 total $ time supervisorctl quickstop app: app:26: stoped app:27: stoped app:22: stoped ...... app:0: stoped app:9: stoped app:8: stoped supervisorctl quickstop app: 0.09s user 0.04s system 68% cpu 0.196 total