【问题标题】:God configuration file to monitor existing processes?神配置文件监控现有进程?
【发布时间】:2023-03-19 04:39:01
【问题描述】:

我正在使用 God(Ruby gem)监控我的 redis 服务器。但是,我现有的服务器可能已经有一个 redis 实例。我如何确定它会监控已启动的现有 Redis 服务器进程?

这是redis的我的上帝文件:

rails_root = ENV['RAILS_ROOT']
redis_root = "/usr/local/bin"

# Redis
%w{6379}.each do |port|
  God.watch do |w|
    w.name          = "redis"
    w.interval      = 30.seconds
    w.start         = "#{redis_root}/redis-server /etc/redis/redis.conf"
    w.stop          = "#{redis_root}/redis-cli shutdown"
    w.restart       = "#{w.stop} && #{w.start}"
    w.start_grace   = 10.seconds
    w.restart_grace = 10.seconds
    w.log           = File.join(rails_root, 'log', 'redis.log')
    w.keepalive(:memory_max => 5000.megabytes)
    w.start_if do |start|
      start.condition(:process_running) do |c|
          c.interval = 5.seconds
          c.running = false
      end
    end
  end
end

【问题讨论】:

    标签: ruby-on-rails ruby redis god


    【解决方案1】:

    回答这个问题:

    我放了一个 w.pid_file = "SOMETHING" 在我的上帝文件中,并确保在 Redis 的配置文件中也设置了这个 PID 文件。

    【讨论】:

      【解决方案2】:

      您还应该添加:

      w.pid_file = "Your_pid_file_name"
      

      然后用

      清理pid文件
      w.behaviour(:clean_pid_file)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-01
        • 1970-01-01
        • 2015-03-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多