有没有可能让上帝依次启动两个过程?
我正在使用依赖 Redis 的 Sidekiq。我想启动 Redis,然后启动 Sidekiq,我设置了两个独立的手表,它们可以独立工作,但是当我运行时:
$ god -c "./config.god" -D
似乎上帝试图同时启动两者,导致 Sidekiq 出错,因为它可以t 连接到 Redis 服务器。
我给上帝的配置文件如下:
# config.god
PROJECT_ROOT = ENV['PROJECT_ROOT'] || "/Path/to/app"
God.watch do |w|
w.name = "redis-server"
w.group = 'conversion-api'
w.interval = 30.seconds
w.start = "/usr/local/Cellar/redis/2.4.16/bin/redis-server"
end
God.watch do |w|
w.name = "sidekiq"
w.group = 'conversion-api'
w.interval = 20.seconds
w.dir = ENV['PROJECT_ROOT']
w.start = "bundle exec sidekiq -v -C #{PROJECT_ROOT}/config.yml -r #{PROJECT_ROOT}/app.rb -c 10"
w.stop = "bundle exec sidekiqctl stop #{PROJECT_ROOT}/tmp/pids/sidekiq.pid 5"
w.keepalive
# Don't pass in a pid file location. Let God handle things. Leaving a pid file location in
# the sidekiq config.yml seems to be harmless though and it lets us force stop sidekiq independently
# of God.
# w.pid_file = File.join(PROJECT_ROOT, 'tmp/pids/sidekiq.pid')
w.log = "./log/god_sidekiq.log"
w.behavior(:clean_pid_file)
end