ruby daemon and bluepill monitoring please help !

Skip to first unread message


Jul 14, 2011, 5:01:30 AM7/14/11
to Bluepill
So i am trying to create a custom daemon to run every 60 seconds and
start / stop and monitor it with bluepill.

Please can someone show me how to do this easier or please can you
tell me what i am doing wrong.

Currently bluepill is starting the daemon so that it runs but seems to
then not know its running as keep trying to stop and start it.

Here is my code from my .pill file

app.process("get_dropboxes") do |process|

process.working_dir = RAILS_ROOT
process.pid_file = File.join(RAILS_ROOT, "tmp", "pids",
process.start_command = "/usr/bin/env RAILS_ENV=#{RAILS_ENV}
bundle exec lib/daemons/get_dropbox_ctl start"
process.stop_command = "/usr/bin/env RAILS_ENV=#{RAILS_ENV}
bundle exec lib/daemons/get_dropbox_ctl stop"

process.start_grace_time = 10.seconds
process.stop_grace_time = 10.seconds
process.restart_grace_time = 10.seconds

process.checks :cpu_usage, :every => 30.seconds, :below =>
20, :times => [3,5]
process.checks :mem_usage, :every => 30.seconds, :below =>
350.megabytes, :times => [3,5]


here is my get_dropbox_ctl file

#!/usr/bin/env ruby
require 'rubygems'
require "daemons"
require 'yaml'
require 'erb'

gem 'activesupport', '>=3.0.0'
require 'active_support'

# For some reason, ActiveSupport 3.0.0 doesn't load.
# Load needed extension directly for now.
require "active_support/core_ext/object"
require "active_support/core_ext/hash"

options = YAML.load(
File.dirname(__FILE__) + "/../../config/daemons.yml"

options[:dir_mode] = options[:dir_mode].to_sym File.dirname(__FILE__) + "/get_dropbox.rb", options

And here is my get_dropbox.rb file

#!/usr/bin/env ruby

# You might want to change this
ENV["RAILS_ENV"] ||= "production"

require 'net/pop'
require File.dirname(__FILE__) + "/../../config/application"

$running = true
Signal.trap("TERM") do
$running = false

while($running) do

# do stuff .......

sleep 60

logs i get

[2011-07-13T16:55:00.464202 #32257] WARN -- :
[] pid_file /var/www/
pids/ does not exist or cannot be read
W, [2011-07-13T16:55:00.464315 #32257] WARN -- :
[] pid_file /var/www/
pids/ does not exist or cannot be read
W, [2011-07-13T16:55:00.464505 #32257] WARN -- :
[] Executing start command: /usr/bin/env
RAILS_ENV=production bundle exec lib/daemons/get_dropbox_ctl start
I, [2011-07-13T16:55:01.602210 #32257] INFO -- :
[] Going from down => starting

Surely there is an easier way than this ?

Please help

Reply all
Reply to author
0 new messages