daemon-kit 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/History.txt +17 -0
  2. data/Manifest.txt +62 -0
  3. data/PostInstall.txt +6 -0
  4. data/README.textile +94 -0
  5. data/Rakefile +31 -0
  6. data/TODO.txt +24 -0
  7. data/app_generators/daemon_kit/USAGE +7 -0
  8. data/app_generators/daemon_kit/daemon_kit_generator.rb +120 -0
  9. data/app_generators/daemon_kit/templates/README +48 -0
  10. data/app_generators/daemon_kit/templates/Rakefile +4 -0
  11. data/app_generators/daemon_kit/templates/bin/daemon.erb +7 -0
  12. data/app_generators/daemon_kit/templates/config/boot.rb +68 -0
  13. data/app_generators/daemon_kit/templates/config/environment.rb +19 -0
  14. data/app_generators/daemon_kit/templates/config/environments/development.rb +0 -0
  15. data/app_generators/daemon_kit/templates/config/environments/production.rb +0 -0
  16. data/app_generators/daemon_kit/templates/config/environments/test.rb +0 -0
  17. data/app_generators/daemon_kit/templates/config/initializers/readme +11 -0
  18. data/app_generators/daemon_kit/templates/libexec/daemon.erb +18 -0
  19. data/bin/daemon_kit +19 -0
  20. data/daemon_generators/amqp/USAGE +5 -0
  21. data/daemon_generators/amqp/amqp_generator.rb +65 -0
  22. data/daemon_generators/amqp/templates/config/amqp.yml +28 -0
  23. data/daemon_generators/amqp/templates/config/initializers/amqp.rb +7 -0
  24. data/daemon_generators/amqp/templates/libexec/daemon.rb +29 -0
  25. data/daemon_generators/cron/USAGE +5 -0
  26. data/daemon_generators/cron/cron_generator.rb +64 -0
  27. data/daemon_generators/cron/templates/config/initializers/cron.rb +7 -0
  28. data/daemon_generators/cron/templates/libexec/daemon.rb +39 -0
  29. data/daemon_generators/jabber/USAGE +5 -0
  30. data/daemon_generators/jabber/jabber_generator.rb +65 -0
  31. data/daemon_generators/jabber/templates/config/initializers/jabber.rb +7 -0
  32. data/daemon_generators/jabber/templates/config/jabber.yml +26 -0
  33. data/daemon_generators/jabber/templates/libexec/daemon.rb +27 -0
  34. data/lib/daemon_kit.rb +14 -0
  35. data/lib/daemon_kit/amqp.rb +41 -0
  36. data/lib/daemon_kit/application.rb +34 -0
  37. data/lib/daemon_kit/cron.rb +38 -0
  38. data/lib/daemon_kit/initializer.rb +255 -0
  39. data/lib/daemon_kit/jabber.rb +172 -0
  40. data/lib/daemon_kit/patches/force_kill_wait.rb +120 -0
  41. data/lib/daemon_kit/tasks.rb +2 -0
  42. data/lib/daemon_kit/tasks/framework.rake +75 -0
  43. data/rubygems_generators/install_rspec/USAGE +5 -0
  44. data/rubygems_generators/install_rspec/install_rspec_generator.rb +57 -0
  45. data/rubygems_generators/install_rspec/templates/spec.rb +11 -0
  46. data/rubygems_generators/install_rspec/templates/spec/spec.opts +1 -0
  47. data/rubygems_generators/install_rspec/templates/spec/spec_helper.rb +10 -0
  48. data/rubygems_generators/install_rspec/templates/tasks/rspec.rake +21 -0
  49. data/script/console +10 -0
  50. data/script/destroy +14 -0
  51. data/script/generate +14 -0
  52. data/script/txt2html +71 -0
  53. data/spec/daemon_kit_spec.rb +7 -0
  54. data/spec/initializer_spec.rb +31 -0
  55. data/spec/spec.opts +1 -0
  56. data/spec/spec_helper.rb +30 -0
  57. data/tasks/rspec.rake +21 -0
  58. data/test/test_amqp_generator.rb +48 -0
  59. data/test/test_cron_generator.rb +45 -0
  60. data/test/test_daemon-kit_generator.rb +67 -0
  61. data/test/test_generator_helper.rb +29 -0
  62. data/test/test_jabber_generator.rb +49 -0
  63. metadata +168 -0
data/History.txt ADDED
@@ -0,0 +1,17 @@
1
+ == 0.1.2 2009-04-28
2
+
3
+ * Added missing rubigen dependency
4
+
5
+ == 0.1.1 2009-04-27
6
+
7
+ * AMQP consumer generator added
8
+ * 'cron' style generator added
9
+ * Allow configuring dir_mode and dir (pid file location) (Jim Lindley)
10
+
11
+ == 0.1.0 2009-01-08
12
+
13
+ * Ability to freeze the gem/edge copies of DaemonKit
14
+ * Simple non-evented Jabber generator
15
+ * Flexible UNIX signal trapping configuration
16
+ * Basic generator completed
17
+ * 1 small step for man, 1 giant leap for mankind
data/Manifest.txt ADDED
@@ -0,0 +1,62 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.textile
5
+ Rakefile
6
+ TODO.txt
7
+ app_generators/daemon_kit/USAGE
8
+ app_generators/daemon_kit/daemon_kit_generator.rb
9
+ app_generators/daemon_kit/templates/README
10
+ app_generators/daemon_kit/templates/Rakefile
11
+ app_generators/daemon_kit/templates/bin/daemon.erb
12
+ app_generators/daemon_kit/templates/config/boot.rb
13
+ app_generators/daemon_kit/templates/config/environment.rb
14
+ app_generators/daemon_kit/templates/config/environments/development.rb
15
+ app_generators/daemon_kit/templates/config/environments/production.rb
16
+ app_generators/daemon_kit/templates/config/environments/test.rb
17
+ app_generators/daemon_kit/templates/config/initializers/readme
18
+ app_generators/daemon_kit/templates/libexec/daemon.erb
19
+ bin/daemon_kit
20
+ daemon_generators/amqp/USAGE
21
+ daemon_generators/amqp/amqp_generator.rb
22
+ daemon_generators/amqp/templates/config/amqp.yml
23
+ daemon_generators/amqp/templates/config/initializers/amqp.rb
24
+ daemon_generators/amqp/templates/libexec/daemon.rb
25
+ daemon_generators/cron/USAGE
26
+ daemon_generators/cron/cron_generator.rb
27
+ daemon_generators/cron/templates/config/initializers/cron.rb
28
+ daemon_generators/cron/templates/libexec/daemon.rb
29
+ daemon_generators/jabber/USAGE
30
+ daemon_generators/jabber/jabber_generator.rb
31
+ daemon_generators/jabber/templates/config/initializers/jabber.rb
32
+ daemon_generators/jabber/templates/config/jabber.yml
33
+ daemon_generators/jabber/templates/libexec/daemon.rb
34
+ lib/daemon_kit.rb
35
+ lib/daemon_kit/amqp.rb
36
+ lib/daemon_kit/application.rb
37
+ lib/daemon_kit/cron.rb
38
+ lib/daemon_kit/initializer.rb
39
+ lib/daemon_kit/jabber.rb
40
+ lib/daemon_kit/patches/force_kill_wait.rb
41
+ lib/daemon_kit/tasks.rb
42
+ lib/daemon_kit/tasks/framework.rake
43
+ rubygems_generators/install_rspec/USAGE
44
+ rubygems_generators/install_rspec/install_rspec_generator.rb
45
+ rubygems_generators/install_rspec/templates/spec.rb
46
+ rubygems_generators/install_rspec/templates/spec/spec.opts
47
+ rubygems_generators/install_rspec/templates/spec/spec_helper.rb
48
+ rubygems_generators/install_rspec/templates/tasks/rspec.rake
49
+ script/console
50
+ script/destroy
51
+ script/generate
52
+ script/txt2html
53
+ spec/daemon_kit_spec.rb
54
+ spec/initializer_spec.rb
55
+ spec/spec.opts
56
+ spec/spec_helper.rb
57
+ tasks/rspec.rake
58
+ test/test_amqp_generator.rb
59
+ test/test_cron_generator.rb
60
+ test/test_daemon-kit_generator.rb
61
+ test/test_generator_helper.rb
62
+ test/test_jabber_generator.rb
data/PostInstall.txt ADDED
@@ -0,0 +1,6 @@
1
+
2
+ For more information on daemon-kit, see http://daemon-kit.rubyforge.org
3
+
4
+ To get started quickly run 'daemon_kit' without any arguments
5
+
6
+
data/README.textile ADDED
@@ -0,0 +1,94 @@
1
+ h1. Daemon Kit
2
+
3
+ * http://daemon-kit.rubyforge.org/ (coming soon)
4
+
5
+ h2. Description
6
+
7
+ Daemon Kit aims to simplify creating Ruby daemons by providing a sound application skeleton (through a generator), task specific generators (jabber bot, etc) and robust environment management code.
8
+
9
+ Using simple built-in generators it is easy to created evented and non-evented daemons that perform a multitude of different tasks.
10
+
11
+ Supported generators:
12
+
13
+ * Evented and non-evented Jabber Bot (coming next)
14
+ * Evented and non-evented loops (coming soon)
15
+ * Queue poller (SQS, AMQP, etc) (coming soon)
16
+
17
+ h2. Features/Problems
18
+
19
+ * Build it
20
+ * Review TODO.txt
21
+
22
+ h2. Synopsis
23
+
24
+ $ daemon-kit [/path/to/your/daemon] [options]
25
+
26
+ The above command generates a skeleton daemon environment for you to adapt.
27
+
28
+ $ daemon-kit [/path/to/your/daemon] -i jabber
29
+
30
+ Use the 'jabber' generator instead of the default one.
31
+
32
+ h2. Generators
33
+
34
+ Currently only two generators exist, a 'default' generator and a 'jabber' generator.
35
+
36
+ The default generator creates a simple daemon with an infinite loop inside that you can adapt.
37
+
38
+ h3. Jabber Generator
39
+
40
+ The jabber generator creates a simple daemon that leverages the "xmpp4r-simple":http://xmpp4r-simple.rubyforge.org/ gem to process inbound messages. The daemon will manage the roster and other little tasks, leaving you to provide the hooks for processing messages, presence notifications and subscription request.
41
+
42
+ h3. Cron Generator
43
+
44
+ The cron generator creates a simple daemon that leverages the "rufus-scheduler":http://github.com/jmettraux/rufus-scheduler gem to create a simple cron-lie daemon. Please be aware that this daemon could never be a replacement for the battle-tested "cron utility":http://www.gentoo.org/doc/en/cron-guide.xml shipped standard with most *nix distributions.
45
+
46
+ h3. AMQP Consumer Generator
47
+
48
+ The AMQP generator creates a simple daemon that has all the stub code and configuration in place to help you write AMQP consumers quickly and effectively. The generated daemon relies on the presence of the "amqp":http://github.com/tmm1/amqp gem.
49
+
50
+ h2. Requirements
51
+
52
+ * Ruby 1.8.6
53
+ * daemons 1.0.10
54
+ * rspec 1.1.11 (for writing/running your specs)
55
+
56
+ h3. Generator Requirements
57
+
58
+ Depending on the generator you choose for your daemon, it might require additional gems to run.
59
+
60
+ |.Generator|.Dependencies|
61
+ |jabber|"xmpp4r-simple":http://xmpp4r-simple.rubyforge.org/|
62
+ |cron|"rufus-scheduler":http://github.com/jmettraux/rufus-scheduler|
63
+ |amqp|"amqp":http://github.com/tmm1/amqp|
64
+
65
+ h2. Install
66
+
67
+ $ git clone git://github.com/kennethkalmer/daemon-kit.git
68
+ $ rake gem
69
+ $ gem install pkg/daemon-kit-X.X.X.gem
70
+
71
+ h2. License
72
+
73
+ (The MIT License)
74
+
75
+ Copyright (c) 2009 Kenneth Kalmer (Internet Exchange CC, Clear Planet Information Solutions Pty Ltd)
76
+
77
+ Permission is hereby granted, free of charge, to any person obtaining
78
+ a copy of this software and associated documentation files (the
79
+ 'Software'), to deal in the Software without restriction, including
80
+ without limitation the rights to use, copy, modify, merge, publish,
81
+ distribute, sublicense, and/or sell copies of the Software, and to
82
+ permit persons to whom the Software is furnished to do so, subject to
83
+ the following conditions:
84
+
85
+ The above copyright notice and this permission notice shall be
86
+ included in all copies or substantial portions of the Software.
87
+
88
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
89
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
90
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
91
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
92
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
93
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
94
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+
2
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
3
+ require File.dirname(__FILE__) + '/lib/daemon_kit'
4
+
5
+ # Generate all the Rake tasks
6
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
7
+ $hoe = Hoe.new('daemon-kit', DaemonKit::VERSION) do |p|
8
+ p.summary = 'Daemon Kit aims to simplify creating Ruby daemons by providing a sound application skeleton (through a generator), task specific generators (jabber bot, etc) and robust environment management code.'
9
+ p.developer('Kenneth Kalmer', 'kenneth.kalmer@gmail.com')
10
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
11
+ p.post_install_message = IO.read( 'PostInstall.txt' ) # TODO remove if post-install message not required
12
+ p.rubyforge_name = p.name # TODO this is default value
13
+ p.extra_deps = [
14
+ ['daemons','>= 1.0.10'],
15
+ ['rubigen', '>= 1.5.2']
16
+ ]
17
+ p.extra_dev_deps = [
18
+ ['newgem', ">= #{::Newgem::VERSION}"]
19
+ ]
20
+
21
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
22
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
23
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
24
+ p.rsync_args = '-av --delete --ignore-errors'
25
+ end
26
+
27
+ require 'newgem/tasks' # load /tasks/*.rake
28
+ Dir['tasks/**/*.rake'].each { |t| load t }
29
+
30
+ # TODO - want other tests/tasks run by default? Add them to the list
31
+ task :default => [:spec] #, :features]
data/TODO.txt ADDED
@@ -0,0 +1,24 @@
1
+ DaemonKit TODO List
2
+ ===================
3
+
4
+ This is purely a drop in the bucket of what has to come...
5
+
6
+ * [DONE] Easy way to trap signals
7
+ * Error handling to the degree Rails does
8
+ * Easy configuration of an ORM of choice, including patching it if needed (ActiveRecord *cough*)
9
+ * Improved generators for creating skeleton daemons:
10
+ * [DONE] Jabber bot
11
+ * Evented jabber bot
12
+ * Empty periodic event loop
13
+ * Empty periodic loop (non-evented)
14
+ * Queue (SQS, AMQP, etc) pollers
15
+ * Rake tasks for generating:
16
+ * god configs
17
+ * Pre-built capistrano configs for easy deployment
18
+ * Support for dropping privileges
19
+ * Support for chroot'ing
20
+ * Improved and cleaned up logging
21
+ * Plenty of docs, seriously a lot of docs
22
+ * Specs & features, tons of them too
23
+ * Some level of thread safety, or mechanisms to ease thread safety
24
+ * DON'T FORGET 1.9 SUPPORT
@@ -0,0 +1,7 @@
1
+ Description:
2
+ This generator creates a new skeleton project suitable for easy
3
+ Ruby daemon development. The generated project is preconfigured
4
+ and just requires your task specific code.
5
+
6
+ Use one of the provided generators to stub out even more
7
+ functionality for common daemon patterns.
@@ -0,0 +1,120 @@
1
+ class DaemonKitGenerator < RubiGen::Base
2
+
3
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
4
+ Config::CONFIG['ruby_install_name'])
5
+
6
+ VALID_GENERATORS = ['default', 'jabber', 'cron', 'amqp']
7
+
8
+ default_options :shebang => DEFAULT_SHEBANG, :author => nil
9
+
10
+ attr_reader :daemon_name
11
+ attr_reader :installer
12
+
13
+ def initialize(runtime_args, runtime_options = {})
14
+ super
15
+ usage if args.empty?
16
+ @destination_root = File.expand_path(args.shift)
17
+ @daemon_name = base_name
18
+ extract_options
19
+ end
20
+
21
+ def manifest
22
+ # ensure some sanity
23
+ unless VALID_GENERATORS.include?( installer )
24
+ $stderr.puts "Invalid generator: '#{installer}'."
25
+ $stderr.puts "Valid generators are: #{VALID_GENERATORS.join(', ')}"
26
+ exit 1
27
+ end
28
+
29
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
30
+
31
+ record do |m|
32
+ # Ensure appropriate folder(s) exists
33
+ m.directory ''
34
+
35
+ # Create stubs
36
+ # m.template "template.rb", "some_file_after_erb.rb"
37
+ # m.template_copy_each ["template.rb", "template2.rb"]
38
+ # m.file "file", "some_file_copied"
39
+ # m.file_copy_each ["path/to/file", "path/to/file2"]
40
+
41
+ # Readme
42
+ m.template "README", "README"
43
+ m.template "Rakefile", "Rakefile"
44
+
45
+ # Executable
46
+ m.directory "bin"
47
+ m.template "bin/daemon.erb", "bin/#{daemon_name}", script_options
48
+
49
+ # Generator
50
+ if installer == "default"
51
+ m.directory "libexec"
52
+ m.template "libexec/daemon.erb", "libexec/#{daemon_name}.rb"
53
+ else
54
+ m.dependency installer, [daemon_name], :destination => destination_root, :collision => :force
55
+ end
56
+
57
+ # Config/Environment
58
+ m.directory "config"
59
+ m.file "config/boot.rb", "config/boot.rb"
60
+ m.template "config/environment.rb", "config/environment.rb"
61
+ m.directory "config/environments"
62
+ %w{ development test production }.each { |f| m.file "config/environments/#{f}.rb", "config/environments/#{f}.rb" }
63
+ m.directory "config/initializers"
64
+ m.file "config/initializers/readme", "config/initializers/readme"
65
+
66
+ # Libraries
67
+ m.directory "lib"
68
+
69
+ # Tests
70
+ m.directory "tasks"
71
+ m.dependency "install_rspec", [daemon_name], :destination => destination_root, :collision => :force
72
+
73
+ # Others
74
+ m.directory "log"
75
+ m.directory "tmp"
76
+ m.directory "vendor"
77
+
78
+ m.dependency "install_rubigen_scripts", [destination_root, 'daemon_kit'],
79
+ :shebang => options[:shebang], :collision => :force
80
+ end
81
+ end
82
+
83
+ protected
84
+ def banner
85
+ <<-EOS
86
+ Creates a preconfigured environment for writing Ruby daemon processes.
87
+
88
+ USAGE: #{spec.name} /path/to/your/daemon [options]
89
+ EOS
90
+ end
91
+
92
+ def add_options!(opts)
93
+ opts.separator ''
94
+ opts.separator 'Options:'
95
+ # For each option below, place the default
96
+ # at the top of the file next to "default_options"
97
+ # opts.on("-a", "--author=\"Your Name\"", String,
98
+ # "Some comment about this option",
99
+ # "Default: none") { |o| options[:author] = o }
100
+ opts.on("-i", "--install=generator", String,
101
+ "Select a generator to use (other than the default).",
102
+ "Available generators: #{VALID_GENERATORS.join(', ')}",
103
+ "Defaults to: default") do |installer|
104
+ options[:installer] = installer
105
+ end
106
+ opts.on("-r", "--ruby=path", String,
107
+ "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
108
+ "Default: #{DEFAULT_SHEBANG}") { |x| options[:shebang] = x }
109
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
110
+ end
111
+
112
+ def extract_options
113
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
114
+ # Templates can access these value via the attr_reader-generated methods, but not the
115
+ # raw instance variable value.
116
+ # @author = options[:author]
117
+ @installer = options[:installer] || 'default'
118
+ end
119
+
120
+ end
@@ -0,0 +1,48 @@
1
+ DaemonKit README
2
+ ================
3
+
4
+ DaemonKit has generated a skeleton Ruby daemon for you to build on. Please read
5
+ through this file to ensure you get going quickly.
6
+
7
+ Directories
8
+ ===========
9
+
10
+ bin/
11
+ <%= daemon_name %> - Stub executable to control your daemon with
12
+
13
+ config/
14
+ Environment configuration files
15
+
16
+ lib/
17
+ Place for your libraries
18
+
19
+ libexec/
20
+ <%= daemon_name %>.rb - Your daemon code
21
+
22
+ log/
23
+ Log files based on the environment name
24
+
25
+ spec/
26
+ rspec's home
27
+
28
+ tasks/
29
+ Place for rake tasks
30
+
31
+ vendor/
32
+ Place for unpacked gems and DaemonKit
33
+
34
+ tmp/
35
+ Scratch folder
36
+
37
+
38
+ Logging
39
+ =======
40
+
41
+ One of the biggest issues with writing daemons are gettign insight into what your
42
+ daemons are doing. Logging with DaemonKit is simplified as DaemonKit creates log
43
+ files per environment in log.
44
+
45
+ On all environments except production the log level is set to DEBUG, but you can
46
+ toggle the log level by sending the running daemon SIGUSR1 and SIGUSR2 signals.
47
+ SIGUSR1 will toggle between DEBUG and INFO levels, SIGUSR2 will blatantly set the
48
+ level to DEBUG.
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'daemon_kit/tasks'
3
+
4
+ Dir[File.join(File.dirname(__FILE__), 'tasks/*.rake')].each { |rake| load rake }
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Stub executable for <%= daemon_name %>
4
+
5
+ require File.dirname(__FILE__) + '/../config/environment'
6
+
7
+ DaemonKit::Application.run( DAEMON_ROOT + '/libexec/<%= daemon_name %>.rb' )
@@ -0,0 +1,68 @@
1
+ # Don't change this file!
2
+ # Configure your daemon in config/environment.rb
3
+
4
+ DAEMON_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?( DAEMON_ROOT )
5
+
6
+ module DaemonKit
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ pick_boot.run
11
+ end
12
+ end
13
+
14
+ def booted?
15
+ defined? DaemonKit::Initializer
16
+ end
17
+
18
+ def pick_boot
19
+ (vendor_kit? ? VendorBoot : GemBoot).new
20
+ end
21
+
22
+ def vendor_kit?
23
+ File.exists?( "#{DAEMON_ROOT}/vendor/daemon_kit" )
24
+ end
25
+ end
26
+
27
+ class Boot
28
+ def run
29
+ load_initializer
30
+ DaemonKit::Initializer.run
31
+ end
32
+ end
33
+
34
+ class VendorBoot < Boot
35
+ def load_initializer
36
+ require "#{DAEMON_ROOT}/vendor/daemon_kit/lib/daemon_kit/initializer"
37
+ end
38
+ end
39
+
40
+ class GemBoot < Boot
41
+ def load_initializer
42
+ begin
43
+ require 'rubygems'
44
+ gem 'kennethkalmer-daemon-kit'
45
+ require 'daemon_kit/initializer'
46
+ rescue Gem::LoadError
47
+ begin
48
+ gem 'daemon-kit'
49
+ require 'daemon_kit/initializer'
50
+ rescue Gem::LoadError => e
51
+ msg = <<EOF
52
+ You are missing the daemon-kit gem. Please install one of the following gems:
53
+
54
+ * Unstable - sudo gem install kennethkalmer-daemon-kit -s http://gems.github.com/
55
+ * Stable - sudo gem install daemon-kit
56
+
57
+ NOTE: The 'unstable' gem is loaded first, before falling back to the stable gem!
58
+
59
+ EOF
60
+ $stderr.puts msg
61
+ exit 1
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ DaemonKit.boot!