新贵的期望/重生可以用于分叉两次以上的进程吗? [英] Can upstart expect/respawn be used on processes that fork more than twice?

查看:74
本文介绍了新贵的期望/重生可以用于分叉两次以上的进程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用upstart启动/停止/自动重启守护程序.其中一个守护程序分叉4次. upstart食谱指出,它仅支持两次分叉.有解决方法吗?

I am using upstart to start/stop/automatically restart daemons. One of the daemons forks 4 times. The upstart cookbook states that it only supports forking twice. Is there a workaround?

如果我尝试使用expect daemonexpect fork,则新贵使用第二个fork的pid.当我尝试停止工作时,没有人响应新贵SIGKILL信号,该信号一直挂起,直到您耗尽pid空间并循环回去为止.如果添加重生,情况会变得更糟.新贵认为这项工作已经死了,并立即开始了另一项工作.

If I try to use expect daemon or expect fork, upstart uses the pid of the second fork. When I try to stop the job, nobody responds to upstarts SIGKILL signal and it hangs until you exhaust the pid space and loop back around. It gets worse if you add respawn. Upstart thinks the job died and immediately starts another one.

已输入错误用于新贵.提出的解决方案仍旧使用旧的sysvinit,重写您的守护程序或等待重写. RHEL比最新的暴发户软件包滞后了将近2年,因此,在发布重写版本和我们进行更新时,等待时间可能为4年.该守护程序由承包商的分包商的分包商编写,因此也不会很快修复.

A bug has been entered for upstart. The solutions presented are stick with the old sysvinit, rewrite your daemon, or wait for a re-write. RHEL is close to 2 years behind the latest upstart package, so by the time the rewrite is released and we get updated the wait will probably be 4 years. The daemon is written by a subcontractor of a subcontractor of a contractor so it will not be fixed any time soon either.

推荐答案

我想出了一个丑陋的技巧来使这项工作生效.它适用于我的系统上的应用程序. YMMV.

I came up with an ugly hack to make this work. It works for my application on my system. YMMV.

  1. 在开始前"部分中启动应用程序
  2. 在脚本部分中运行一个脚本,该脚本在应用程序运行时一直运行.该脚本的pid是新手要跟踪的内容.
  3. 停止后部分中杀死应用程序

示例

env DAEMON=/usr/bin/forky-application

pre-start script
    su -s /bin/sh -c "$DAEMON" joeuseraccount
end script

script 
    sleepWhileAppIsUp(){
        while pidof $1 >/dev/null; do
            sleep 1
        done
    }

    sleepWhileAppIsUp $DAEMON
end script

post-stop script
    if pidof $DAEMON;
    then
        kill `pidof $DAEMON`
        #pkill  $DAEMON # post-stop process (19300) terminated with status 1
    fi
end script

可以对pid文件采用类似的方法.

a similar approach could be taken with pid files.

这篇关于新贵的期望/重生可以用于分叉两次以上的进程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆