linux网页控制项目,从网页(Rails)控制Linux进程的最佳做法是什么?

感谢@xvidun,我找到了解决办法:使用god。

关键的过程是:如何使非守护进程作为守护进程启动。 “nohup ... &”不适合我。所以我尝试了上帝,这太棒了!

在我的情况下,这个过程中我要运行是:

$ cd /sg552/workspace/m-video-fetcher

$ nohup ruby script/start_fetch.rb &

这里是我做的工作:

第一步:创建一个上帝的配置文件:

# file name: fetcher.god

RAILS_ROOT = '/sg552/workspace/m-video-fetcher'

God.watch do |w|

w.name = 'fetcher'

w.dir = RAILS_ROOT

w.start = "ruby script/start_fetch.rb"

w.log = "#{RAILS_ROOT}/fetcher_stdout.log"

w.keepalive

end

step2:

$ god start -c fetcher.god

第三步:

# in the view, give users the interface to restart this job.

restart

# in the controller:

def restart_fetch_for_all_plans

result = `god stop fetcher && god start fetcher`

redirect_to :back, :notice => "fetcher restarted, #{result}"

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值