6

I am using BluePill to manage processes such as delayed job for Rails. In the BluePill log, I am getting this message:

W, [2010-09-27T01:23:20.447053 #19441]  WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read
W, [2010-09-27T01:23:20.447368 #19441]  WARN -- : [fsg_distro:delayed_job] Executing start command: ruby script/delayed_job -e production start
I, [2010-09-27T01:23:20.469165 #19441]  INFO -- : [fsg_distro:delayed_job] Going from down => starting

So it's claiming that a pid file is missing, which it is, but shouldn't that pid be created when BluePill starts the Delayed Job process?

Update To be a bit more clear about this error, I can successfully run the command manually but Bluepill fails to run the start command. When I run it manually, it looks like this:

rails@george:/srv/fsg_distro/current$ /usr/bin/env RAILS_ENV=production /usr/bin/ruby /srv/fsg_distro/current/script/delayed_job start
delayed_job: process with pid 17564 started. 

When I run it with Bluepill it looks like this:

W, [2010-10-03T21:24:13.943136 #17326]  WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read
W, [2010-10-03T21:24:13.943391 #17326]  WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read
I, [2010-10-03T21:24:13.943811 #17326]  INFO -- : [fsg_distro:delayed_job] Going from starting => down
W, [2010-10-03T21:24:14.945274 #17326]  WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read
W, [2010-10-03T21:24:14.945495 #17326]  WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read
W, [2010-10-03T21:24:14.945826 #17326]  WARN -- : [fsg_distro:delayed_job] Executing start command: /usr/bin/env RAILS_ENV=production /usr/bin/ruby /srv/fsg_distro/current/script/delayed_job start
W, [2010-10-03T21:24:15.049261 #17326]  WARN -- : [fsg_distro:delayed_job] Start command execution returned non-zero exit code:
W, [2010-10-03T21:24:15.049491 #17326]  WARN -- : [fsg_distro:delayed_job] {:stderr=>"", :exit_code=>1, :stdout=>""} 
I, [2010-10-03T21:24:15.049947 #17326]  INFO -- : [fsg_distro:delayed_job] Going from down => starting 

My pill looks like this:

APP_ROOT='/srv/fsg_distro'
RAILS_ROOT='/srv/fsg_distro/current'
RAILS_ENV='production'
RUBY_EXEC='/usr/bin/ruby'

Bluepill.application("fsg_distro", :log_file => "/srv/fsg_distro/shared/log/bluepill.log") do |app|
  app.process("delayed_job") do |process|
    process.working_dir = RAILS_ROOT

    process.start_grace_time    = 30.seconds
    process.stop_grace_time     = 30.seconds
    process.restart_grace_time  = 30.seconds

    process.start_command = "/usr/bin/env RAILS_ENV=#{RAILS_ENV} #{RUBY_EXEC} #{RAILS_ROOT}/script/delayed_job start"
    process.stop_command  = "/usr/bin/env RAILS_ENV=#{RAILS_ENV} #{RUBY_EXEC} #{RAILS_ROOT}/script/delayed_job stop"

    process.pid_file = "#{APP_ROOT}/shared/pids/delayed_job.pid"
    process.uid = "deploy"
    process.gid = "deploy"
  end
end 

And my delayed job script looks like this:

#!/usr/bin/env ruby
ENV['RAILS_ENV'] ||= 'production'

require File.dirname(__FILE__) + '/../config/environment'
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize 
3
  • 1
    2 questions seeing as how this is still unanswered. What permission would you need to write to the folder /srv/fsg_distro/shared/pids/ and does the user rails (from the machine george ?) have those permissions ?
    – Hugo
    Oct 6, 2010 at 14:17
  • Bluepill and me logged in are the same user.... As long as the user is the owner or in the group, he can write to the pids directory
    – Tony
    Oct 8, 2010 at 1:01
  • @Tony Same issue here, did you ever manage to solve this?
    – DelPiero
    Apr 15, 2019 at 20:03

2 Answers 2

2

If you daemonize delayed_job (which you are) then you must generate a pid file for it yourself, or get delayed_job to do it for you, then bluepill expects to find the pid file once grace_start_time has passed.

If you run delayed_job in the foreground, and you tell bluepill to daemonize the process for you, then bluepill will generate the pid file.

You can't both monitor a self-daemonizing process and have bluepill create a pid file. It's either one or the other.

1

I have no answer, but exactly the same question. I have tried many, many solutions--including creating a startup script for init.d and calling that from bluepill as described in another monit-based posting (http://stackoverflow.com/questions/1226302/how-to-monitor-delayed-job-with-monit), but nothing has worked. Always there is a permissions issue with the PID file. How could this be the case when running as su?

I own the code, and share it with group www. Do I need to create a custom user just to run bluepill? If so, with what settings?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.