Skip to content

Instantly share code, notes, and snippets.

@kennethkalmer
Created July 31, 2009 18:05
Show Gist options
  • Save kennethkalmer/159349 to your computer and use it in GitHub Desktop.
Save kennethkalmer/159349 to your computer and use it in GitHub Desktop.
#
# daemon-kit stack configuration
#
# severe pseudo-code example
#
#
# config/environment.rb (shared stack)
#
DaemonKit::Initializer.run do |config|
config.daemon_name = 'default-name'
config.force_kill_wait = 30
config.backtraces = true
# easier dependencies
config.depends "ruote"
# pre-daemonize stuff, transient stack member
config.before_daemonize do
end
# other ways of pre/post daemonizing can look like this
# config.after_daemonize "booted" # <- config/booted.rb
# This stack member will check for the presence of the amqp gem prior to daemonizing,
# but only connect to the amqp server after daemonizing
config.stack :amqp do |amqp|
# whatever is needed
end
# check ruby version prior to daemonizing, create pool after booting...
config.stack :fibre_pool do |pool|
pool.members = 5
pool.ready! # heat up the pool
end
config.stack :bar # custom stack, see end of gist
# custom daemons evaluated here...
end
#
# config/initialize/foo.rb custom stack for specific daemon
#
config.daemon_name 'esb'
config.stack :xmpp do |jabber|
# Now we have AMQP and XMPP, the start of an esb :)
end
#
# config/initialize/no-amqp.rb stack for a daemon without amqp
#
config.name 'boring'
config.strip :amqp # voids amqp from default stack
#
# config/stacks/bar_stack.rb
#
DaemonKit::Stack.create :bar do |config|
config.stack :activerecord
config.stack :something
config.stack :something_else
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment