bunnicula 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/Rakefile +2 -2
  2. data/bunnicula.gemspec +180 -3
  3. data/lib/bunnicula/version.rb +1 -1
  4. data/vendor/daemon_kit/daemon-kit/Configuration.txt +110 -0
  5. data/vendor/daemon_kit/daemon-kit/Deployment.txt +113 -0
  6. data/vendor/daemon_kit/daemon-kit/History.txt +113 -0
  7. data/vendor/daemon_kit/daemon-kit/Logging.txt +96 -0
  8. data/vendor/daemon_kit/daemon-kit/Manifest.txt +172 -0
  9. data/vendor/daemon_kit/daemon-kit/PostInstall.txt +6 -0
  10. data/vendor/daemon_kit/daemon-kit/README.rdoc +126 -0
  11. data/vendor/daemon_kit/daemon-kit/Rakefile +29 -0
  12. data/vendor/daemon_kit/daemon-kit/RuoteParticipants.txt +113 -0
  13. data/vendor/daemon_kit/daemon-kit/TODO.txt +28 -0
  14. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/USAGE +7 -0
  15. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/daemon_kit_generator.rb +178 -0
  16. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/README +48 -0
  17. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/Rakefile +6 -0
  18. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/bin/daemon.erb +7 -0
  19. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/arguments.rb +12 -0
  20. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/boot.rb +59 -0
  21. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/environment.rb +23 -0
  22. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/environments/development.rb +2 -0
  23. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/environments/production.rb +5 -0
  24. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/environments/test.rb +2 -0
  25. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/post-daemonize/readme +5 -0
  26. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/config/pre-daemonize/readme +12 -0
  27. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/lib/daemon.rb +2 -0
  28. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/libexec/daemon.erb +18 -0
  29. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/script/console +3 -0
  30. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/script/destroy +14 -0
  31. data/vendor/daemon_kit/daemon-kit/app_generators/daemon_kit/templates/script/generate +14 -0
  32. data/vendor/daemon_kit/daemon-kit/bin/daemon-kit +18 -0
  33. data/vendor/daemon_kit/daemon-kit/config/website.yml +2 -0
  34. data/vendor/daemon_kit/daemon-kit/daemon-kit.gemspec +264 -0
  35. data/vendor/daemon_kit/daemon-kit/daemon_generators/amqp/USAGE +5 -0
  36. data/vendor/daemon_kit/daemon-kit/daemon_generators/amqp/amqp_generator.rb +65 -0
  37. data/vendor/daemon_kit/daemon-kit/daemon_generators/amqp/templates/config/amqp.yml +28 -0
  38. data/vendor/daemon_kit/daemon-kit/daemon_generators/amqp/templates/config/initializers/amqp.rb +7 -0
  39. data/vendor/daemon_kit/daemon-kit/daemon_generators/amqp/templates/libexec/daemon.rb +37 -0
  40. data/vendor/daemon_kit/daemon-kit/daemon_generators/cron/USAGE +5 -0
  41. data/vendor/daemon_kit/daemon-kit/daemon_generators/cron/cron_generator.rb +64 -0
  42. data/vendor/daemon_kit/daemon-kit/daemon_generators/cron/templates/config/initializers/cron.rb +11 -0
  43. data/vendor/daemon_kit/daemon-kit/daemon_generators/cron/templates/libexec/daemon.rb +43 -0
  44. data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/USAGE +11 -0
  45. data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/cucumber_generator.rb +38 -0
  46. data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/templates/cucumber +8 -0
  47. data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/templates/cucumber.rake +13 -0
  48. data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/templates/cucumber_environment.rb +2 -0
  49. data/vendor/daemon_kit/daemon-kit/daemon_generators/cucumber/templates/env.rb +7 -0
  50. data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb +35 -0
  51. data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/Capfile +10 -0
  52. data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/USAGE +10 -0
  53. data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy.rb +53 -0
  54. data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/production.rb +6 -0
  55. data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb +6 -0
  56. data/vendor/daemon_kit/daemon-kit/daemon_generators/deploy_capistrano/templates/config/environments/staging.rb +0 -0
  57. data/vendor/daemon_kit/daemon-kit/daemon_generators/jabber/USAGE +5 -0
  58. data/vendor/daemon_kit/daemon-kit/daemon_generators/jabber/jabber_generator.rb +65 -0
  59. data/vendor/daemon_kit/daemon-kit/daemon_generators/jabber/templates/config/initializers/jabber.rb +7 -0
  60. data/vendor/daemon_kit/daemon-kit/daemon_generators/jabber/templates/config/jabber.yml +26 -0
  61. data/vendor/daemon_kit/daemon-kit/daemon_generators/jabber/templates/libexec/daemon.rb +27 -0
  62. data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/USAGE +5 -0
  63. data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/nanite_agent_generator.rb +68 -0
  64. data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/templates/config/initializers/nanite_agent.rb +6 -0
  65. data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/templates/config/nanite.yml +35 -0
  66. data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/templates/lib/actors/sample.rb +11 -0
  67. data/vendor/daemon_kit/daemon-kit/daemon_generators/nanite_agent/templates/libexec/daemon.rb +31 -0
  68. data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/USAGE +5 -0
  69. data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/rspec_generator.rb +55 -0
  70. data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/templates/spec.rb +11 -0
  71. data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/templates/spec/spec.opts +1 -0
  72. data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/templates/spec/spec_helper.rb +23 -0
  73. data/vendor/daemon_kit/daemon-kit/daemon_generators/rspec/templates/tasks/rspec.rake +19 -0
  74. data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/USAGE +5 -0
  75. data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/ruote_generator.rb +67 -0
  76. data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/config/amqp.yml +30 -0
  77. data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/config/initializers/ruote.rb +13 -0
  78. data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/config/ruote.yml +23 -0
  79. data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/lib/daemon.rb +4 -0
  80. data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/lib/sample.rb +26 -0
  81. data/vendor/daemon_kit/daemon-kit/daemon_generators/ruote/templates/libexec/daemon.rb +33 -0
  82. data/vendor/daemon_kit/daemon-kit/daemon_generators/test_unit/USAGE +5 -0
  83. data/vendor/daemon_kit/daemon-kit/daemon_generators/test_unit/templates/tasks/test_unit.rake +7 -0
  84. data/vendor/daemon_kit/daemon-kit/daemon_generators/test_unit/templates/test/test.rb +9 -0
  85. data/vendor/daemon_kit/daemon-kit/daemon_generators/test_unit/templates/test/test_helper.rb +6 -0
  86. data/vendor/daemon_kit/daemon-kit/daemon_generators/test_unit/test_unit_generator.rb +51 -0
  87. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit.rb +62 -0
  88. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/abstract_logger.rb +241 -0
  89. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/amqp.rb +38 -0
  90. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/application.rb +188 -0
  91. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/arguments.rb +170 -0
  92. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/commands/console.rb +38 -0
  93. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/config.rb +108 -0
  94. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/console_daemon.rb +2 -0
  95. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/core_ext.rb +1 -0
  96. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/core_ext/configurable.rb +96 -0
  97. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/core_ext/string.rb +22 -0
  98. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/cron.rb +48 -0
  99. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/cucumber/world.rb +38 -0
  100. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/deployment/capistrano.rb +482 -0
  101. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/em.rb +43 -0
  102. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/error_handlers/base.rb +32 -0
  103. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/error_handlers/hoptoad.rb +61 -0
  104. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/error_handlers/mail.rb +85 -0
  105. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/exceptions.rb +15 -0
  106. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/initializer.rb +453 -0
  107. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/jabber.rb +170 -0
  108. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/nanite.rb +7 -0
  109. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/nanite/agent.rb +77 -0
  110. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/pid_file.rb +61 -0
  111. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/ruote_participants.rb +119 -0
  112. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/ruote_pseudo_participant.rb +68 -0
  113. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/ruote_workitem.rb +177 -0
  114. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/safety.rb +85 -0
  115. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks.rb +2 -0
  116. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks/environment.rake +10 -0
  117. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks/framework.rake +120 -0
  118. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks/god.rake +62 -0
  119. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks/log.rake +8 -0
  120. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/tasks/monit.rake +29 -0
  121. data/vendor/daemon_kit/daemon-kit/lib/daemon_kit/xmpp.rb +31 -0
  122. data/vendor/daemon_kit/daemon-kit/script/console +10 -0
  123. data/vendor/daemon_kit/daemon-kit/script/destroy +14 -0
  124. data/vendor/daemon_kit/daemon-kit/script/generate +14 -0
  125. data/vendor/daemon_kit/daemon-kit/script/txt2html +71 -0
  126. data/vendor/daemon_kit/daemon-kit/spec/abstract_logger_spec.rb +126 -0
  127. data/vendor/daemon_kit/daemon-kit/spec/argument_spec.rb +70 -0
  128. data/vendor/daemon_kit/daemon-kit/spec/config_spec.rb +79 -0
  129. data/vendor/daemon_kit/daemon-kit/spec/configurable_spec.rb +56 -0
  130. data/vendor/daemon_kit/daemon-kit/spec/daemon_kit_spec.rb +7 -0
  131. data/vendor/daemon_kit/daemon-kit/spec/error_handlers_spec.rb +23 -0
  132. data/vendor/daemon_kit/daemon-kit/spec/fixtures/env.yml +15 -0
  133. data/vendor/daemon_kit/daemon-kit/spec/fixtures/noenv.yml +4 -0
  134. data/vendor/daemon_kit/daemon-kit/spec/initializer_spec.rb +26 -0
  135. data/vendor/daemon_kit/daemon-kit/spec/spec.opts +1 -0
  136. data/vendor/daemon_kit/daemon-kit/spec/spec_helper.rb +27 -0
  137. data/vendor/daemon_kit/daemon-kit/tasks/cucumber.rake +13 -0
  138. data/vendor/daemon_kit/daemon-kit/tasks/rspec.rake +21 -0
  139. data/vendor/daemon_kit/daemon-kit/tasks/tests.rake +6 -0
  140. data/vendor/daemon_kit/daemon-kit/templates/god/god.erb +69 -0
  141. data/vendor/daemon_kit/daemon-kit/templates/monit/monit.erb +14 -0
  142. data/vendor/daemon_kit/daemon-kit/test/test_amqp_generator.rb +48 -0
  143. data/vendor/daemon_kit/daemon-kit/test/test_cron_generator.rb +45 -0
  144. data/vendor/daemon_kit/daemon-kit/test/test_daemon-kit_generator.rb +84 -0
  145. data/vendor/daemon_kit/daemon-kit/test/test_daemon_kit_config.rb +28 -0
  146. data/vendor/daemon_kit/daemon-kit/test/test_deploy_capistrano_generator.rb +48 -0
  147. data/vendor/daemon_kit/daemon-kit/test/test_generator_helper.rb +29 -0
  148. data/vendor/daemon_kit/daemon-kit/test/test_helper.rb +7 -0
  149. data/vendor/daemon_kit/daemon-kit/test/test_jabber_generator.rb +49 -0
  150. data/vendor/daemon_kit/daemon-kit/test/test_nanite_agent_generator.rb +49 -0
  151. data/vendor/daemon_kit/daemon-kit/test/test_ruote_generator.rb +51 -0
  152. data/vendor/daemon_kit/daemon-kit/test/test_test_unit_generator.rb +46 -0
  153. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail.rb +5 -0
  154. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/address.rb +426 -0
  155. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/attachments.rb +46 -0
  156. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/base64.rb +46 -0
  157. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/compat.rb +41 -0
  158. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/config.rb +67 -0
  159. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/core_extensions.rb +63 -0
  160. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/encode.rb +581 -0
  161. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/header.rb +960 -0
  162. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/index.rb +9 -0
  163. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/interface.rb +1130 -0
  164. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/loader.rb +3 -0
  165. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/mail.rb +578 -0
  166. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/mailbox.rb +495 -0
  167. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/main.rb +6 -0
  168. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/mbox.rb +3 -0
  169. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/net.rb +248 -0
  170. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/obsolete.rb +132 -0
  171. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/parser.rb +1476 -0
  172. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/port.rb +379 -0
  173. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/quoting.rb +118 -0
  174. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/require_arch.rb +58 -0
  175. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/scanner.rb +49 -0
  176. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/scanner_r.rb +261 -0
  177. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/stringio.rb +280 -0
  178. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/utils.rb +337 -0
  179. data/vendor/daemon_kit/daemon-kit/vendor/tmail-1.2.3/tmail/version.rb +39 -0
  180. data/vendor/daemon_kit/daemon-kit/vendor/tmail.rb +13 -0
  181. metadata +181 -4
@@ -0,0 +1,28 @@
1
+ = DaemonKit TODO List
2
+
3
+ This is purely a drop in the bucket of what has to come...
4
+
5
+ * Support for chroot'ing
6
+ * Altering process names (fully and temporary appending)
7
+ * bleak_house support
8
+ * Support for tweaking REE environment variables prior to launch (bash wrapper)
9
+ * Clustering support (run multiple workers out of same project)
10
+ * [IN PROGRESS] Error handling to the degree Rails does
11
+ * Support for custom error handlers in the project
12
+ * Easy configuration of an ORM of choice, including patching it if needed (ActiveRecord *cough*)
13
+ * Improved generators for creating skeleton daemons:
14
+ * Evented jabber bot
15
+ * Empty periodic event loop
16
+ * Empty periodic loop (non-evented)
17
+ * Queue (SQS, AMQP, etc) pollers
18
+ * Rake tasks for generating:
19
+ * Sys-V style init scripts
20
+ * Plenty of docs, seriously a lot of docs
21
+ * Specs & features, tons of them too
22
+ * Integration tests for the specific daemons
23
+ * Some level of thread safety, or mechanisms to ease thread safety
24
+ * Built in utilities:
25
+ * Fibre pool for 1.9
26
+ * Some activesupport-esque functions until activesupport 3.0 hits the streets
27
+ * DRY up the following:
28
+ * Loading configuration files for the daemons
@@ -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,178 @@
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', 'nanite_agent', 'ruote']
7
+
8
+ DEPLOYERS = ['none', 'capistrano']
9
+
10
+ TEST_FRAMEWORKS = [ 'rspec', 'test_unit' ]
11
+
12
+ default_options :shebang => DEFAULT_SHEBANG, :author => nil
13
+
14
+ attr_reader :daemon_name
15
+ attr_reader :installer
16
+ attr_reader :deployer
17
+ attr_reader :cucumber
18
+ attr_reader :test_framework
19
+
20
+ def initialize(runtime_args, runtime_options = {})
21
+ super
22
+ usage if args.empty?
23
+ @destination_root = File.expand_path(args.shift)
24
+ @daemon_name = base_name
25
+ extract_options
26
+ end
27
+
28
+ def manifest
29
+ # ensure some sanity
30
+ unless VALID_GENERATORS.include?( installer )
31
+ $stderr.puts "Invalid generator: '#{installer}'."
32
+ $stderr.puts "Valid generators are: #{VALID_GENERATORS.join(', ')}"
33
+ exit 1
34
+ end
35
+
36
+ unless DEPLOYERS.include?( deployer )
37
+ $stderr.puts "Invalid deployment mechanism: '#{deployer}'."
38
+ $stderr.puts "Valid deployers are: #{DEPLOYERS.join(', ')}"
39
+ exit 1
40
+ end
41
+
42
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
43
+
44
+ record do |m|
45
+ # Ensure appropriate folder(s) exists
46
+ m.directory ''
47
+
48
+ # Create stubs
49
+ # m.template "template.rb", "some_file_after_erb.rb"
50
+ # m.template_copy_each ["template.rb", "template2.rb"]
51
+ # m.file "file", "some_file_copied"
52
+ # m.file_copy_each ["path/to/file", "path/to/file2"]
53
+
54
+ # Readme
55
+ m.template "README", "README"
56
+ m.template "Rakefile", "Rakefile"
57
+
58
+ # Executable
59
+ m.directory "bin"
60
+ m.template "bin/daemon.erb", "bin/#{daemon_name}", script_options
61
+
62
+ # Generator
63
+ if installer == "default"
64
+ m.directory "libexec"
65
+ m.template "libexec/daemon.erb", "libexec/#{daemon_name}-daemon.rb"
66
+ else
67
+ m.dependency installer, [daemon_name], :destination => destination_root, :collision => :force
68
+ end
69
+
70
+ # Config/Environment
71
+ m.directory "config"
72
+ m.file "config/arguments.rb", "config/arguments.rb"
73
+ m.file "config/boot.rb", "config/boot.rb"
74
+ m.template "config/environment.rb", "config/environment.rb"
75
+ m.directory "config/environments"
76
+ %w{ development test production }.each { |f| m.file "config/environments/#{f}.rb", "config/environments/#{f}.rb" }
77
+ m.directory "config/pre-daemonize"
78
+ m.file "config/pre-daemonize/readme", "config/pre-daemonize/readme"
79
+ m.directory "config/post-daemonize"
80
+ m.file "config/post-daemonize/readme", "config/post-daemonize/readme"
81
+ m.directory "script"
82
+ m.file "script/destroy", "script/destroy", script_options
83
+ m.file "script/console", "script/console", script_options
84
+ m.file "script/generate", "script/generate", script_options
85
+
86
+ # Libraries
87
+ m.directory "lib"
88
+ m.file "lib/daemon.rb", "lib/#{daemon_name}.rb", :collision => :skip
89
+
90
+ # Tasks
91
+ m.directory "tasks"
92
+
93
+ # Tests
94
+ case test_framework
95
+ when 'rspec'
96
+ m.dependency "rspec", [daemon_name], :destination => destination_root, :collision => :force
97
+ when 'test_unit'
98
+ m.dependency "test_unit", [daemon_name], :destination => destination_root, :collision => :force
99
+ end
100
+
101
+ if cucumber
102
+ m.dependency "cucumber", [], :destination => destination_root, :collision => :force
103
+ end
104
+
105
+ # Deployers
106
+ unless deployer == 'none'
107
+ m.dependency "deploy_#{deployer}", [daemon_name], :destination => destination_root, :collision => :force
108
+ end
109
+
110
+ # Others
111
+ m.directory "log"
112
+ m.directory "tmp"
113
+ m.directory "vendor"
114
+ end
115
+ end
116
+
117
+ protected
118
+ def banner
119
+ <<-EOS
120
+ Creates a preconfigured environment for writing Ruby daemon processes.
121
+
122
+ USAGE: #{spec.name} /path/to/your/daemon [options]
123
+ EOS
124
+ end
125
+
126
+ def add_options!(opts)
127
+ opts.separator ''
128
+ opts.separator 'Options:'
129
+ # For each option below, place the default
130
+ # at the top of the file next to "default_options"
131
+ # opts.on("-a", "--author=\"Your Name\"", String,
132
+ # "Some comment about this option",
133
+ # "Default: none") { |o| options[:author] = o }
134
+
135
+ opts.on("-i", "--install=generator", String,
136
+ "Select a generator to use (other than the default).",
137
+ "Available generators: #{VALID_GENERATORS.join(', ')}",
138
+ "Defaults to: default") do |installer|
139
+ options[:installer] = installer
140
+ end
141
+
142
+ opts.on("-d", "--deploy-with=config", String,
143
+ "Select an optional deployment mechanism.",
144
+ "Available deployers: #{DEPLOYERS.join(', ')}",
145
+ "Defaults to: none") do |deploy|
146
+ options[:deployer] = deploy
147
+ end
148
+
149
+ opts.on("-T", "--test-with=type", String,
150
+ "Select your test framework.",
151
+ "Available test framworks: #{TEST_FRAMEWORKS.join(', ')}",
152
+ "Defaults to: rspec") do |test|
153
+ options[:test_framework] = test
154
+ end
155
+
156
+ opts.on("--cucumber",
157
+ "Install cucumber.") do
158
+ options[:cucumber] = true
159
+ end
160
+
161
+ opts.on("-r", "--ruby=path", String,
162
+ "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
163
+ "Default: #{DEFAULT_SHEBANG}") { |x| options[:shebang] = x }
164
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
165
+ end
166
+
167
+ def extract_options
168
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
169
+ # Templates can access these value via the attr_reader-generated methods, but not the
170
+ # raw instance variable value.
171
+ # @author = options[:author]
172
+ @installer = options[:installer] || 'default'
173
+ @deployer = (options[:deployer] || 'none').strip
174
+ @cucumber = options[:cucumber] || false
175
+ @test_framework = options[:test_framework] || 'rspec'
176
+ end
177
+
178
+ 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,6 @@
1
+ require File.dirname(__FILE__) + '/config/boot'
2
+
3
+ require 'rake'
4
+ require 'daemon_kit/tasks'
5
+
6
+ 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.exec( DAEMON_ROOT + '/libexec/<%= daemon_name %>-daemon.rb' )
@@ -0,0 +1,12 @@
1
+ # Argument handling for your daemon is configured here.
2
+ #
3
+ # You have access to two variables when this file is
4
+ # parsed. The first is +opts+, which is the object yielded from
5
+ # +OptionParser.new+, the second is +@options+ which is a standard
6
+ # Ruby hash that is later accessible through
7
+ # DaemonKit.arguments.options and can be used in your daemon process.
8
+
9
+ # Here is an example:
10
+ # opts.on('-f', '--foo FOO', 'Set foo') do |foo|
11
+ # @options[:foo] = foo
12
+ # end
@@ -0,0 +1,59 @@
1
+ # Don't change this file!
2
+ # Configure your daemon in config/environment.rb
3
+
4
+ DAEMON_ROOT = "#{File.expand_path(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
+ gem 'daemon-kit'
44
+ require 'daemon_kit/initializer'
45
+ rescue Gem::LoadError => e
46
+ msg = <<EOF
47
+ You are missing the daemon-kit gem. Please install the following gems:
48
+
49
+ * Stable - sudo gem install daemon-kit
50
+
51
+ EOF
52
+ $stderr.puts msg
53
+ exit 1
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ DaemonKit.boot!
@@ -0,0 +1,23 @@
1
+ # Be sure to restart your daemon when you modify this file
2
+
3
+ # Uncomment below to force your daemon into production mode
4
+ #ENV['DAEMON_ENV'] ||= 'production'
5
+
6
+ # Boot up
7
+ require File.join(File.dirname(__FILE__), 'boot')
8
+
9
+ DaemonKit::Initializer.run do |config|
10
+
11
+ # The name of the daemon as reported by process monitoring tools
12
+ config.daemon_name = '<%= daemon_name %>'
13
+
14
+ # Force the daemon to be killed after X seconds from asking it to
15
+ # config.force_kill_wait = 30
16
+
17
+ # Log backraces when a thread/daemon dies (Recommended)
18
+ # config.backtraces = true
19
+
20
+ # Configure the safety net (see DaemonKit::Safety)
21
+ # config.safety_net.handler = :mail # (or :hoptoad )
22
+ # config.safety_net.mail.host = 'localhost'
23
+ end
@@ -0,0 +1,2 @@
1
+ # This is the same context as the environment.rb file, it is only
2
+ # loaded afterwards and only in the development environment
@@ -0,0 +1,5 @@
1
+ # This is the same context as the environment.rb file, it is only
2
+ # loaded afterwards and only in the production environment
3
+
4
+ # Change the production log level to debug
5
+ #config.log_level = :debug
@@ -0,0 +1,2 @@
1
+ # This is the same context as the environment.rb file, it is only
2
+ # loaded afterwards and only in the test environment
@@ -0,0 +1,5 @@
1
+ # You can place files in here to be loaded after the code is daemonized.
2
+ #
3
+ # All the files placed here will just be required into the running
4
+ # process. This is the correct place to open any IO objects, establish
5
+ # database connections, etc.
@@ -0,0 +1,12 @@
1
+ # You can place files in here to be loaded before the code is daemonized.
2
+ #
3
+ # DaemonKit looks for a file named '<config.daemon_name>.rb' and loads
4
+ # that file first, and inside a DaemonKit::Initializer block. The
5
+ # remaning files then simply required into the running process.
6
+ #
7
+ # These files are mostly useful for operations that should fail blatantly
8
+ # before daemonizing, like loading gems.
9
+ #
10
+ # Be careful not to open any form of IO in here and expecting it to be
11
+ # open inside the running daemon since all IO instances are closed when
12
+ # daemonizing (including STDIN, STDOUT & STDERR).
@@ -0,0 +1,2 @@
1
+ # Your starting point for daemon specific classes. This directory is
2
+ # already included in your load path, so no need to specify it.
@@ -0,0 +1,18 @@
1
+ # Change this file to be a wrapper around your daemon code.
2
+
3
+ # Do your post daemonization configuration here
4
+ # At minimum you need just the first line (without the block), or a lot
5
+ # of strange things might start happening...
6
+ DaemonKit::Application.running! do |config|
7
+ # Trap signals with blocks or procs
8
+ # config.trap( 'INT' ) do
9
+ # # do something clever
10
+ # end
11
+ # config.trap( 'TERM', Proc.new { puts 'Going down' } )
12
+ end
13
+
14
+ # Sample loop to show process
15
+ loop do
16
+ DaemonKit.logger.info "I'm running"
17
+ sleep 60
18
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'daemon_kit/commands/console'
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:daemon, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)