gpt4 book ai didi

ruby - 如何指定守护进程的日志和 pid 目录?

转载 作者:数据小太阳 更新时间:2023-10-29 07:18:10 25 4
gpt4 key购买 nike

使用守护进程,我如何指定我的脚本的日志进入/log/而它的 pid 进入/tmp/pids/?

我已经阅读了文档,我看到了 :dir/:dir_mode,但我只能让它做一个或另一个,而不是两个 — 如果你问我,这似乎是一组非常糟糕的选项。

最佳答案

看起来 vanilla Daemons 不能做你想做的事,但它是可以修复的。尝试这样的事情:

require 'rubygems'
require 'daemons'

module Daemons
class Application
def logfile; '/log/f1'; end
def output_logfile; '/log/f2'; end
end
end

Daemons.run '/tmp/test.rb',
:dir => '/tmp/pids',
:dir_mode => :normal,
:ontop => false,
:log_output => true

您可能希望 *logfile 的逻辑更像原来的逻辑;只需扫描 def.logfile 的守护程序源。我也宁愿修补 Application 的子类,但它是在模块 Daemons 的其他地方按名称实例化的,所以这让事情变得棘手。

关于ruby - 如何指定守护进程的日志和 pid 目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1560773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com