0
RAILS_ROOT = File.dirname(File.dirname(__FILE__))

God.watch do |w|
  pid_file = File.join(RAILS_ROOT, "tmp/pids/server.pid")

  w.name = "thin"
  w.interval = 60.seconds
  w.start = "rails server -e production"
  w.stop = "kill -s QUIT $(cat #{pid_file})"
  w.restart = "kill -s HUP $(cat #{pid_file})"
  w.start_grace = 20.seconds
  w.restart_grace = 20.seconds
  w.pid_file = pid_file

  w.behavior(:clean_pid_file)

  # When to start?
  w.start_if do |start|
    start.condition(:process_running) do |c|
      # We want to check if deamon is running every ten seconds
      # and start it if itsn't running
      c.interval = 10.seconds
      c.running = false
    end
  end

我试过 w.start = "rails server -e production" 但它说它不起作用

信息:瘦“向上”移动到“向上”我 [2014-05-02 23:37:09] 信息:瘦 [触发器] 进程未运行(ProcessRunning)我 [2014-05-02 23:37:09]信息:细移动“向上”到“开始”

4

1 回答 1

0

为瘦创建一个 rake 任务

namespace :server do
  desc "start thin server"
  task start: :environment do
    puts Rails.root
     `cd #{Rails.root}`
     str  = "rails s -e production"
     puts "Starting server" 
     `#{str}`
  end
end

像这样开始

w.start = "cd #{RAILS_ROOT} && rake server:start"

如果你使用 exec rails s -e prodution 那么上帝守护进程将被退出并且你得到 server unavailbale 错误。所以你需要一个 rake 任务

于 2014-05-03T06:42:14.807 回答