I am not aware that god monitors its config files itself.
I use sinotify to monitor the pid files, to see if an external event
changed/reloaded a running proces
Such a thing could be done to have god reload the config if it is
changed.
The following is an example. It uses a hook which does not exist in
God by default, and has to be called after all config files are
loaded: God.afterload_filechange
# depends sinotify gem
require 'rubygems'
require 'sinotify'
module God
def self.afterload_filechange
FileChangeEvents.run
end
module FileChangeEvents
@@registered_files = {}
def self.register file, &block
@@registered_files[file] = block
end
def self.deregister file
@@registered_files[file] = nil
end
def self.addFile file
@@registered_files[file] ||= nil
end
def self.notify(sinotify_event)
file = sinotify_event.path
callback = @@registered_files[file]
unless callback.nil?
callback.call(sinotify_event.etypes, file)
end
end
def self.run
@@registered_files.keys.map{|file|
File.dirname(file) }.uniq.each do |folder|
notifier = Sinotify::Notifier.new(folder, :recurse =>
false, :etypes => [:create, :modify, :delete])
notifier.on_event do |sinotify_event|
FileChangeEvents.notify(sinotify_event)
end
notifier.watch!
end
end
end
module Conditions
class PidfileChanged < EventCondition
def initialize
self.info = "Got a change in my pid file"
end
def valid?
true
end
def register
FileChangeEvents.register(self.watch.pid_file) do |method,
file|
self.watch.trigger(self) unless method.include? :delete
end
msg = "#{self.watch.name} registered 'PidfileChanged' event"
applog(self.watch, :info, msg)
end
def deregister
FileChangeEvents.deregister(self.watch.pid_file)
msg = "#{self.watch.name} deregistered 'PidfileChanged' event"
applog(self.watch, :info, msg)
end
end
end
class Watch < Task
def pid_file= pid_file
FileChangeEvents.addFile pid_file
@process.pid_file = pid_file
end
end
end
On Mar 30, 10:05 pm, Fabien Penso <[email protected]> wrote:
> +1 , is there any?
>
> On Mar 19, 5:37 am, blaines <[email protected]> wrote:
>
> > Hey there, just curious if God already reloads a script/config when
> > it's changed or if there's a way to set it up to do so. Looking for
> > behavior similar to passenger's restart.txt. Not sure if this feature
> > is a good idea or not.
>
> > Thanks!
--
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.