supervisor 的使用范围有限制吗?

2015-08-01 09:44:43 +08:00
 hzqim
系统:Debian 7 64bit

在 /etc/supervisor/conf.d 下放有两个 conf 文件,一个 ss.conf ,一个 mytest.conf 。

ss.conf 和 mytest.conf 分别为:

[program:ss]
command=/usr/local/bin/ssserver -c /etc/ss.json
autorestart=true
user=root

[program:mytest]
command=/usr/bin/mytest
autorestart=true
user=root

运行supervisorctl reload,日志如下:

2015-08-01 09:27:14,124 CRIT Supervisor running as root (no user in config file)
2015-08-01 09:27:14,124 WARN Included extra file "/etc/supervisor/conf.d/ss.conf" during parsing
2015-08-01 09:27:14,124 WARN Included extra file "/etc/supervisor/conf.d/mytest.conf" during parsing
2015-08-01 09:27:14,124 INFO RPC interface 'supervisor' initialized
2015-08-01 09:27:14,124 WARN cElementTree not installed, using slower XML parser for XML-RPC
2015-08-01 09:27:14,124 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2015-08-01 09:27:14,124 INFO supervisord started with pid 14297
2015-08-01 09:27:15,126 INFO spawned: 'ss' with pid 14956
2015-08-01 09:27:15,127 INFO spawned: 'mytest' with pid 14957
2015-08-01 09:27:15,135 INFO exited: mytest (exit status 1; not expected)
2015-08-01 09:27:16,326 INFO success: ss entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2015-08-01 09:27:16,327 INFO spawned: 'mytest' with pid 14970
2015-08-01 09:27:16,331 INFO exited: mytest (exit status 1; not expected)
2015-08-01 09:27:19,073 INFO spawned: 'mytest' with pid 14973
2015-08-01 09:27:19,077 INFO exited: mytest (exit status 1; not expected)
2015-08-01 09:27:22,935 INFO spawned: 'mytest' with pid 14975
2015-08-01 09:27:22,939 INFO exited: mytest (exit status 1; not expected)
2015-08-01 09:27:23,940 INFO gave up: mytest entered FATAL state, too many start retries too quickly

从日志中可以看到,mytest 总是 abnormal termination 异常终止!

file mytest ,返回如下:
/usr/bin/mytest: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

这个mytest直接运行没有成功或者是错误提示,ps -ef |grep mytest ,进程存在。
现在的疑问是,mytest 是否是守护进程?supervisor是否不能对守护进程进行监视?


谢谢答疑!
5455 次点击
所在节点    Linux
11 条回复
ryd994
2015-08-01 10:28:12 +08:00
手动运行mystart的话,是不是会立刻返回?那就是fork到后台了,fork出来的进程当然无法识别。有几种办法
查查mystart文档,有没有foreground或者不fork的选项
使用pid文件,配置supervisor

另外,自从用了systemd,就再没用过其他了
ryd994
2015-08-01 10:31:29 +08:00
手动运行mystart的话,是不是会立刻返回?那就是fork到后台了,fork出来的进程当然无法识别。有几种办法
查查mystart文档,有没有foreground或者不fork的选项
使用pid文件,让supervisor识别

另外,systemd大法好
felixzhu
2015-08-01 10:51:50 +08:00
supervisor不能对守护进程进行监视,mytest自己本身就是守护进程

如果你要用supervisor统一管理就要加参数前台执行
hzqim
2015-08-01 10:52:45 +08:00
@ryd994 谢谢,确实有 foreground 和 pid 选项,supervisorctl reload 之后能够启动进程,但 kill 之后,不能自动重启。
hzqim
2015-08-01 11:02:14 +08:00
@ryd994
@felixzhu
通过强制foreground终于弄好了,谢谢两位!
lilydjwg
2015-08-01 11:04:49 +08:00
systemd大法+1. cgroup 是很棒的特性,还有 subreaper 也是,可 supervisord 还不支持。
ryd994
2015-08-01 11:41:48 +08:00
@hzqim kill不能重启应该也是supervisor配置问题,查查控制重启的选项
hzqim
2015-08-01 12:17:19 +08:00
@lilydjwg 谢谢介绍,systemd 还没有接触过,找时间看看这个争议比较大的启动管理。

@ryd994 启用 foreground 之后,可以正常启动了,谢谢您一而再,再而三的解答,1024个赞!
TankyWoo
2015-08-01 15:42:27 +08:00
supervisor , daemontools这类服务管理工具都要求是前台运行的
xargs
2015-08-01 21:40:51 +08:00
楼主用supervisor 好吧 看看我的问题
我的是起不来http://v2ex.com/t/210122#reply10
hzqim
2015-08-01 22:43:37 +08:00
@xargs 您好,您的问题出现在 supervisor 启动失败,修改一下 config 中的 supervisor.sock 路径,可以参考一下这篇文章:
http://lixcto.blog.51cto.com/4834175/1539136
希望对您有用。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/209999

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX