Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Problems with God monitoring backgroundrb?

View parsed - Show only message text

Received: by 10.115.19.16 with SMTP id w16mr7928513wai.25.1204373700766;
        Sat, 01 Mar 2008 04:15:00 -0800 (PST)
Return-Path: <g...@spork.in>
Received: from plastic.spork.in (plastic.spork.in [67.207.130.88])
        by mx.google.com with ESMTP id k36si3175097waf.0.2008.03.01.04.15.00;
        Sat, 01 Mar 2008 04:15:00 -0800 (PST)
Received-SPF: pass (google.com: best guess record for domain of g...@spork.in designates 67.207.130.88 as permitted sender) client-ip=67.207.130.88;
Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of g...@spork.in designates 67.207.130.88 as permitted sender) smtp.mai...@spork.in
Received: from [172.16.10.104] (unknown [172.16.10.104])
	(Authenticated sender: t...@halorgium.net)
	by plastic.spork.in (Postfix) with ESMTP id 3D5E4DC10F
	for <god-rb@googlegroups.com>; Sun,  2 Mar 2008 01:14:58 +1300 (NZDT)
Message-Id: <2EE8FF52-857B-49BD-AF1C-AB0CEE20126F@spork.in>
From: Tim Carey-Smith <g...@spork.in>
To: god-rb@googlegroups.com
In-Reply-To: <6bba442a-0ff5-4547-96d5-245755e1d3f3@d4g2000prg.googlegroups.com>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (Apple Message framework v919.2)
Subject: Re: Problems with God monitoring backgroundrb?
Date: Sun, 2 Mar 2008 01:14:33 +1300
References: <1211da5f-d57f-4aef-804d-8ffe559b335d@v46g2000hsv.googlegroups.com> <6bba442a-0ff5-4547-96d5-245755e1d3f3@d4g2000prg.googlegroups.com>
X-Mailer: Apple Mail (2.919.2)

On 1/03/2008, at 10:32 AM, James H. wrote:

> Did you ever get God working with BDRb?  I'm working on
> building a test site right now for an app that uses BDRb and I was
> looking around for advice on the matter.
If you are using any self-daemonizing application, you should specify  
the pid-file.

Here is a watch and script I use inside a rails app.
It is using the 'daemons' gem and works wonders :)

Cheers,
Tim

## START WATCH ##
God.watch do |w|
   base_path = "/home/deploy/foobar"
   w.name = "foobar-daemon"
   w.uid = "deploy"
   w.gid = "nogroup"
   w.pid_file = "#{base_path}/shared/log/foobar.pid"
   w.interval = 30.seconds
   w.start   = "#{base_path}/current/script/daemon start    --  
production"
   w.stop    = "#{base_path}/current/script/daemon stop     --  
production"
   w.restart = "#{base_path}/current/script/daemon restart  --  
production"
   w.start_grace = 10.seconds
   w.restart_grace = 10.seconds

   w.behavior(:clean_pid_file)

   w.start_if do |start|
     start.condition(:process_running) do |c|
       c.interval = 5.seconds
       c.running = false
     end
   end
end
## END WATCH ##

## START DAEMON ##
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'

code = File.dirname(__FILE__) + "/../lib/scripts/daemon.rb"
options = {
   :app_name   => "foobar-daemon",
   :ARGV       => ARGV,
   :dir_mode   => :normal,
   :dir        => File.dirname(__FILE__) + '/../log',
   :multiple   => false,
   :backtrace  => true,
   :monitor    => false
}
Daemons.run(code, options)
## END DAEMON ##


Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google