gpt4 book ai didi

用大神监控redis——监控条件

转载 作者:IT王子 更新时间:2023-10-29 06:03:12 25 4
gpt4 key购买 nike

我试图用 god 监控 redis,但 god 试图重新启动它,即使它已经在运行。这是我的 .god 脚本(移植自 http://blog.thomasmango.com/post/636319317/resque-in-production ):

# Redis
%w{6379}.each do |port|
God.watch do |w|
w.name = "redis-server"
w.interval = 30.seconds
w.start = "/etc/init.d/redis-server start"
w.stop = "/etc/init.d/redis-server stop"
w.restart = "/etc/init.d/redis-server restart"
w.start_grace = 10.seconds
w.restart_grace = 10.seconds

w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 5.seconds
c.running = false
end
end
end
end

现在当我像这样开始上帝时:

god -c /home/phlegx/workspace/projectx/config/god/config.god -D --log-level debug

我得到以下输出:

I [2011-04-28 18:32:10]  INFO: Loading /home/phlegx/workspace/projectx/config/god/config.god
I [2011-04-28 18:32:10] INFO: Syslog enabled.
I [2011-04-28 18:32:10] INFO: Using pid file directory: /var/run/god
I [2011-04-28 18:32:10] INFO: Started on drbunix:///tmp/god.17165.sock
I [2011-04-28 18:32:10] INFO: redis-server move 'unmonitored' to 'up'
D [2011-04-28 18:32:10] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x000000020929d0> in 0 seconds
I [2011-04-28 18:32:10] INFO: redis-server moved 'unmonitored' to 'up'
I [2011-04-28 18:32:10] INFO: redis-server [trigger] process is not running (ProcessRunning)
D [2011-04-28 18:32:10] DEBUG: redis-server ProcessRunning [true] {true=>:start}
I [2011-04-28 18:32:10] INFO: redis-server move 'up' to 'start'
I [2011-04-28 18:32:10] INFO: redis-server start: /etc/init.d/redis-server start
D [2011-04-28 18:32:20] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x000000020929d0> in 0 seconds
I [2011-04-28 18:32:20] INFO: redis-server moved 'up' to 'up'
I [2011-04-28 18:32:20] INFO: redis-server [trigger] process is not running (ProcessRunning)
D [2011-04-28 18:32:20] DEBUG: redis-server ProcessRunning [true] {true=>:start}
I [2011-04-28 18:32:20] INFO: redis-server move 'up' to 'start'
I [2011-04-28 18:32:20] INFO: redis-server start: /etc/init.d/redis-server start

D [2011-04-28 18:32:30] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x000000020929d0> in 0 seconds
I [2011-04-28 18:32:30] INFO: redis-server moved 'up' to 'up'
I [2011-04-28 18:32:30] INF (ProcessRunning)O: redis-server [trigger] process is not running
D [2011-04-28 18:32:30] DEBUG: redis-server ProcessRunning [true] {true=>:start}
I [2011-04-28 18:32:30] INFO: redis-server move 'up' to 'start'
I [2011-04-28 18:32:30] INFO: redis-server start: /etc/init.d/redis-server start

如您所见,它总是提示:

INF (ProcessRunning)O: redis-server [trigger] process is not running

有谁知道这可能导致什么?

god 写到“/var/run/god/redis-server.pid”的 PID 似乎和我执行“ps”时不一样:

ps aux | grep redis
redis 7702 0.0 0.0 9876 1376 ? Ss 18:00 0:01 /usr/bin/redis-server /etc/redis/redis.conf

“redis-server.pid”中的PID不应该和“ps”显示的一样吗?

最佳答案

我不熟悉 god (ehehe),但我怀疑它希望 Redis 不会自行守护进程(就像 daemontools 那样)。如果是这种情况,您应该关闭 redis 配置文件中的 self 守护进程。 IIRC 是“daemonize=yes”参数,改成no。这可能对你有用。

现在,如果是这种情况,PID 文件可能不同的原因是 god 可能正在启动它并记录 PID,然后当 redis-server 命令返回时它认为 Redis 已死并尝试重新启动。此时它将记录一个新的 PID。如果正在运行的 PID 小于文件中的 PID,这很明显。

关于用大神监控redis——监控条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5822097/

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