mongrel重启时清除过期的pid_file

1
2
3
4
5
6
7
8
9
10
11
12
13
if File.exist? defaults[:pid_file]
  # mongrels that crash can leave stale PID files behind, and these
  # should not stop mongrel from being restarted by monitors...
  pid = File.new(defaults[:pid_file]).readline
  unless `ps -ef | grep #{pid} | grep -v grep`.length > 0
    # use "ps ax" for freebsd 
    log "!!! PID file #{defaults[:pid_file]} exists, but is stale, and will be deleted so that this mongrel can run."
    File.delete(defaults[:pid_file])
  else
    log "!!! PID file #{defaults[:pid_file]} already exists and the process id referred to in it is running.  This mongrel is probably already running.  #{defaults[:log_file]} for errors.  EXITING."
    exit 1
  end
end

/usr/local/lib/ruby/gems/1.8/gems/mongrel-x.x.x/bin/mongrel_rails

    Posted by devon At June 27, 2008 15:41

请登录以发表评论。