module God
  module System
    class Process
      alias_method :orig_fetch_system_poller, :fetch_system_poller
      def fetch_system_poller
        if `hostname` =~ /YOUR CENTOS HOST(S) HERE/
          PortablePoller
        else
          orig_fetch_system_poller
        end
      end
    end
  end
  class Process
    def spawn(command)
      fork do
        uid_num = Etc.getpwnam(self.uid).uid if self.uid
        gid_num = Etc.getgrnam(self.gid).gid if self.gid

        ::Process.groups = [gid_num] if self.gid
        ::Process::Sys.setgid(gid_num) if self.gid
        ::Process::Sys.setuid(uid_num) if self.uid

        $0 = command
        STDIN.reopen "/dev/null"
        STDOUT.reopen file_in_chroot(self.log), "a"
        STDERR.reopen STDOUT

        # close any other file descriptors
        3.upto(256){|fd| IO::new(fd).close rescue nil}

        if self.env && self.env.is_a?(Hash)
          self.env.each do |(key, value)|
            ENV[key] = value
          end
        end

        exec command unless command.empty?
      end
    end
  end
end


On Thu, Nov 6, 2008 at 2:01 AM, Tigris <[EMAIL PROTECTED]> wrote:
>
> On Sep 14, 1:06 pm, None <[EMAIL PROTECTED]> wrote:
>> I've found and fixed my problem(s).  Turns out the let-god-demonize
>> thing was a red herring.  The fixes were to use the PortablePoller on
>> CENTOS, and to modify God::System::Process#spawn not to perform chroot
>> and chdir.  Voila!
>
> I don't suppose anyone can explain a bit better on how to achieve
> this? I'm experiencing the same problems outlined here on CENTOS also.
> Kill the processes manually after loading god and it doesn't even see
> the fact they died, nor do I see it polling in the logs, it just sits
> there apparently doing nothing.
>
> #######################
> def make_fail_safe(watcher)
>  watcher.lifecycle do |on|
>    on.condition(:flapping) do |c|
>      c.to_state     = [:start, :restart]
>      c.times        = 5
>      c.within       = 5.minutes
>      c.transition   = :unmonitored
>      c.retry_in     = 10.minutes
>      c.retry_times  = 5
>      c.retry_within = 2.hours
>    end
>  end
> end
>
> God.watch do |w|
>  w.name     = 'apache'
>  w.pid_file = '/var/run/httpd.pid'
>  w.interval = 60.seconds
>
>  w.start   = '/etc/init.d/httpd start'
>  w.stop    = '/etc/init.d/httpd stop'
>  w.restart = '/etc/init.d/httpd graceful'
>
>  w.start_grace   = 20.seconds
>  w.restart_grace = 20.seconds
>
>  w.behavior(:clean_pid_file)
>
>  w.restart_if do |r|
>    r.condition(:cpu_usage)   {|c| c.notify = 'developers'; c.above =
> 80.percent;    c.times = 5}
>    r.condition(:cpu_usage)   {|c| c.notify = 'developers'; c.above =
> 60.percent;    c.times = 2}
>    r.condition(:memory_usage){|c| c.notify = 'developers'; c.above =
> 500.megabytes; c.times = 5}
>    r.condition(:http_response_code) do |c|
>      c.notify      = 'developers'
>      c.host        = 'www.example.com'
>      c.path        = '/god'
>      c.code_is_not = 200
>      c.timeout     = 2.seconds
>    end
>  end
>
>  make_fail_safe(w)
> end
>
> God.contact(:email) do |c|
>  c.name  = 'Me'
>  c.email = '[EMAIL PROTECTED]'
>  c.group = 'developers'
> end
> #######################
>
>
> regards,
> Danial
> >
>



-- 
Colin Steele
www.colinsteele.org
[EMAIL PROTECTED]
Ken Kesey - "Ritual is necessary for us to know anything."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"god.rb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/god-rb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to