Skip to content

Instantly share code, notes, and snippets.

@erikh

erikh/service.rb Secret

Created January 17, 2012 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikh/9f5813409cf0f9daed5d to your computer and use it in GitHub Desktop.
Save erikh/9f5813409cf0f9daed5d to your computer and use it in GitHub Desktop.
class AService < SM::Service
monitor :flap, :action => :stop, :tries => 2
groups [ :cool_service, :fart ]
# this works
config_from :chef, :databag => "services", :item => "a_service"
config_from :redis, :hash => "a_service"
config_from :dus, :url => "http://some.thing.com/service.json"
# or this
def start
exec "fart"
end
def stop(pid)
kill(pid)
end
# or this
start_command "fart"
pidfile "/var/run/fart.pid" # pids should be tracked automatically unless this is specified.
# custom monitors can be defined at any point
def custom_monitor
# ping isn't a real function, just an idea of how this would work
ping("host") == 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment