V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
hzqim
V2EX  ›  Linux

supervisor 的使用范围有限制吗?

  •  
  •   hzqim · 2015-08-01 09:44:43 +08:00 · 5448 次点击
    这是一个创建于 3184 天前的主题,其中的信息可能已经有所发展或是发生改变。
    系统: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是否不能对守护进程进行监视?


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

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

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

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

    @ryd994 启用 foreground 之后,可以正常启动了,谢谢您一而再,再而三的解答,1024个赞!
    TankyWoo
        9
    TankyWoo  
       2015-08-01 15:42:27 +08:00   ❤️ 1
    supervisor , daemontools这类服务管理工具都要求是前台运行的
    xargs
        10
    xargs  
       2015-08-01 21:40:51 +08:00
    楼主用supervisor 好吧 看看我的问题
    我的是起不来http://v2ex.com/t/210122#reply10
    hzqim
        11
    hzqim  
    OP
       2015-08-01 22:43:37 +08:00
    @xargs 您好,您的问题出现在 supervisor 启动失败,修改一下 config 中的 supervisor.sock 路径,可以参考一下这篇文章:
    http://lixcto.blog.51cto.com/4834175/1539136
    希望对您有用。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2746 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:46 · PVG 22:46 · LAX 07:46 · JFK 10:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.