apphunkd 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +18 -0
  5. data/Rakefile +78 -0
  6. data/TODO +1 -0
  7. data/VERSION +1 -0
  8. data/apphunkd.gemspec +258 -0
  9. data/bin/apphunkd +4 -0
  10. data/config/arguments.rb +12 -0
  11. data/config/boot.rb +68 -0
  12. data/config/environment.rb +23 -0
  13. data/config/environments/development.rb +2 -0
  14. data/config/environments/production.rb +2 -0
  15. data/config/environments/test.rb +2 -0
  16. data/config/post-daemonize/readme +5 -0
  17. data/config/pre-daemonize/readme +12 -0
  18. data/config/pre-daemonize/requires.rb +2 -0
  19. data/lib/apphunkd.rb +25 -0
  20. data/lib/apphunkd/api.rb +5 -0
  21. data/lib/apphunkd/api/service.rb +27 -0
  22. data/lib/apphunkd/queue.rb +96 -0
  23. data/lib/apphunkd/remote.rb +29 -0
  24. data/lib/apphunkd/remote/result.rb +15 -0
  25. data/libexec/apphunkd-daemon.rb +13 -0
  26. data/script/console +3 -0
  27. data/script/destroy +14 -0
  28. data/script/generate +14 -0
  29. data/spec/lib/apphunkd/api/service_spec.rb +47 -0
  30. data/spec/lib/apphunkd/queue_spec.rb +129 -0
  31. data/spec/lib/apphunkd/remote_spec.rb +61 -0
  32. data/spec/lib/apphunkd_spec.rb +50 -0
  33. data/spec/spec.opts +1 -0
  34. data/spec/spec_helper.rb +13 -0
  35. data/support/apphunkd.initd +47 -0
  36. data/support/apphunkd.monitrc +3 -0
  37. data/tasks/rspec.rake +21 -0
  38. data/vendor/daemon-kit/Configuration.txt +102 -0
  39. data/vendor/daemon-kit/Deployment.txt +113 -0
  40. data/vendor/daemon-kit/History.txt +97 -0
  41. data/vendor/daemon-kit/Logging.txt +92 -0
  42. data/vendor/daemon-kit/Manifest.txt +166 -0
  43. data/vendor/daemon-kit/PostInstall.txt +6 -0
  44. data/vendor/daemon-kit/README.rdoc +130 -0
  45. data/vendor/daemon-kit/Rakefile +37 -0
  46. data/vendor/daemon-kit/RuoteParticipants.txt +113 -0
  47. data/vendor/daemon-kit/TODO.txt +37 -0
  48. data/vendor/daemon-kit/app_generators/daemon_kit/USAGE +7 -0
  49. data/vendor/daemon-kit/app_generators/daemon_kit/daemon_kit_generator.rb +161 -0
  50. data/vendor/daemon-kit/app_generators/daemon_kit/templates/README +48 -0
  51. data/vendor/daemon-kit/app_generators/daemon_kit/templates/Rakefile +6 -0
  52. data/vendor/daemon-kit/app_generators/daemon_kit/templates/bin/daemon.erb +7 -0
  53. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/arguments.rb +12 -0
  54. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/boot.rb +68 -0
  55. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environment.rb +23 -0
  56. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/development.rb +2 -0
  57. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/production.rb +2 -0
  58. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/test.rb +2 -0
  59. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/post-daemonize/readme +5 -0
  60. data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/pre-daemonize/readme +12 -0
  61. data/vendor/daemon-kit/app_generators/daemon_kit/templates/lib/daemon.rb +2 -0
  62. data/vendor/daemon-kit/app_generators/daemon_kit/templates/libexec/daemon.erb +18 -0
  63. data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/console +3 -0
  64. data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/destroy +14 -0
  65. data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/generate +14 -0
  66. data/vendor/daemon-kit/bin/daemon_kit +18 -0
  67. data/vendor/daemon-kit/daemon_generators/amqp/USAGE +5 -0
  68. data/vendor/daemon-kit/daemon_generators/amqp/amqp_generator.rb +65 -0
  69. data/vendor/daemon-kit/daemon_generators/amqp/templates/config/amqp.yml +28 -0
  70. data/vendor/daemon-kit/daemon_generators/amqp/templates/config/initializers/amqp.rb +7 -0
  71. data/vendor/daemon-kit/daemon_generators/amqp/templates/libexec/daemon.rb +37 -0
  72. data/vendor/daemon-kit/daemon_generators/cron/USAGE +5 -0
  73. data/vendor/daemon-kit/daemon_generators/cron/cron_generator.rb +64 -0
  74. data/vendor/daemon-kit/daemon_generators/cron/templates/config/initializers/cron.rb +11 -0
  75. data/vendor/daemon-kit/daemon_generators/cron/templates/libexec/daemon.rb +43 -0
  76. data/vendor/daemon-kit/daemon_generators/cucumber/USAGE +11 -0
  77. data/vendor/daemon-kit/daemon_generators/cucumber/cucumber_generator.rb +38 -0
  78. data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber +8 -0
  79. data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber.rake +13 -0
  80. data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber_environment.rb +2 -0
  81. data/vendor/daemon-kit/daemon_generators/cucumber/templates/env.rb +7 -0
  82. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb +35 -0
  83. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/Capfile +10 -0
  84. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/USAGE +10 -0
  85. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy.rb +53 -0
  86. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/production.rb +6 -0
  87. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb +6 -0
  88. data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/environments/staging.rb +0 -0
  89. data/vendor/daemon-kit/daemon_generators/jabber/USAGE +5 -0
  90. data/vendor/daemon-kit/daemon_generators/jabber/jabber_generator.rb +65 -0
  91. data/vendor/daemon-kit/daemon_generators/jabber/templates/config/initializers/jabber.rb +7 -0
  92. data/vendor/daemon-kit/daemon_generators/jabber/templates/config/jabber.yml +26 -0
  93. data/vendor/daemon-kit/daemon_generators/jabber/templates/libexec/daemon.rb +27 -0
  94. data/vendor/daemon-kit/daemon_generators/nanite_agent/USAGE +5 -0
  95. data/vendor/daemon-kit/daemon_generators/nanite_agent/nanite_agent_generator.rb +68 -0
  96. data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/config/initializers/nanite_agent.rb +6 -0
  97. data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/config/nanite.yml +35 -0
  98. data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/lib/actors/sample.rb +11 -0
  99. data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/libexec/daemon.rb +31 -0
  100. data/vendor/daemon-kit/daemon_generators/rspec/USAGE +5 -0
  101. data/vendor/daemon-kit/daemon_generators/rspec/rspec_generator.rb +55 -0
  102. data/vendor/daemon-kit/daemon_generators/rspec/templates/spec.rb +11 -0
  103. data/vendor/daemon-kit/daemon_generators/rspec/templates/spec/spec.opts +1 -0
  104. data/vendor/daemon-kit/daemon_generators/rspec/templates/spec/spec_helper.rb +21 -0
  105. data/vendor/daemon-kit/daemon_generators/rspec/templates/tasks/rspec.rake +21 -0
  106. data/vendor/daemon-kit/daemon_generators/ruote/USAGE +5 -0
  107. data/vendor/daemon-kit/daemon_generators/ruote/ruote_generator.rb +67 -0
  108. data/vendor/daemon-kit/daemon_generators/ruote/templates/config/amqp.yml +30 -0
  109. data/vendor/daemon-kit/daemon_generators/ruote/templates/config/initializers/ruote.rb +13 -0
  110. data/vendor/daemon-kit/daemon_generators/ruote/templates/config/ruote.yml +23 -0
  111. data/vendor/daemon-kit/daemon_generators/ruote/templates/lib/daemon.rb +4 -0
  112. data/vendor/daemon-kit/daemon_generators/ruote/templates/lib/sample.rb +26 -0
  113. data/vendor/daemon-kit/daemon_generators/ruote/templates/libexec/daemon.rb +33 -0
  114. data/vendor/daemon-kit/lib/daemon_kit.rb +54 -0
  115. data/vendor/daemon-kit/lib/daemon_kit/abstract_logger.rb +235 -0
  116. data/vendor/daemon-kit/lib/daemon_kit/amqp.rb +38 -0
  117. data/vendor/daemon-kit/lib/daemon_kit/application.rb +187 -0
  118. data/vendor/daemon-kit/lib/daemon_kit/arguments.rb +165 -0
  119. data/vendor/daemon-kit/lib/daemon_kit/commands/console.rb +38 -0
  120. data/vendor/daemon-kit/lib/daemon_kit/config.rb +108 -0
  121. data/vendor/daemon-kit/lib/daemon_kit/console_daemon.rb +2 -0
  122. data/vendor/daemon-kit/lib/daemon_kit/core_ext.rb +1 -0
  123. data/vendor/daemon-kit/lib/daemon_kit/core_ext/configurable.rb +96 -0
  124. data/vendor/daemon-kit/lib/daemon_kit/core_ext/string.rb +22 -0
  125. data/vendor/daemon-kit/lib/daemon_kit/cron.rb +48 -0
  126. data/vendor/daemon-kit/lib/daemon_kit/cucumber/world.rb +38 -0
  127. data/vendor/daemon-kit/lib/daemon_kit/deployment/capistrano.rb +482 -0
  128. data/vendor/daemon-kit/lib/daemon_kit/em.rb +43 -0
  129. data/vendor/daemon-kit/lib/daemon_kit/error_handlers/base.rb +32 -0
  130. data/vendor/daemon-kit/lib/daemon_kit/error_handlers/hoptoad.rb +61 -0
  131. data/vendor/daemon-kit/lib/daemon_kit/error_handlers/mail.rb +85 -0
  132. data/vendor/daemon-kit/lib/daemon_kit/exceptions.rb +8 -0
  133. data/vendor/daemon-kit/lib/daemon_kit/initializer.rb +438 -0
  134. data/vendor/daemon-kit/lib/daemon_kit/jabber.rb +170 -0
  135. data/vendor/daemon-kit/lib/daemon_kit/nanite.rb +7 -0
  136. data/vendor/daemon-kit/lib/daemon_kit/nanite/agent.rb +56 -0
  137. data/vendor/daemon-kit/lib/daemon_kit/pid_file.rb +61 -0
  138. data/vendor/daemon-kit/lib/daemon_kit/ruote_participants.rb +119 -0
  139. data/vendor/daemon-kit/lib/daemon_kit/ruote_pseudo_participant.rb +68 -0
  140. data/vendor/daemon-kit/lib/daemon_kit/ruote_workitem.rb +169 -0
  141. data/vendor/daemon-kit/lib/daemon_kit/safety.rb +85 -0
  142. data/vendor/daemon-kit/lib/daemon_kit/tasks.rb +2 -0
  143. data/vendor/daemon-kit/lib/daemon_kit/tasks/environment.rake +10 -0
  144. data/vendor/daemon-kit/lib/daemon_kit/tasks/framework.rake +120 -0
  145. data/vendor/daemon-kit/lib/daemon_kit/tasks/god.rake +62 -0
  146. data/vendor/daemon-kit/lib/daemon_kit/tasks/log.rake +8 -0
  147. data/vendor/daemon-kit/lib/daemon_kit/tasks/monit.rake +29 -0
  148. data/vendor/daemon-kit/script/console +10 -0
  149. data/vendor/daemon-kit/script/destroy +14 -0
  150. data/vendor/daemon-kit/script/generate +14 -0
  151. data/vendor/daemon-kit/script/txt2html +71 -0
  152. data/vendor/daemon-kit/spec/abstract_logger_spec.rb +126 -0
  153. data/vendor/daemon-kit/spec/argument_spec.rb +70 -0
  154. data/vendor/daemon-kit/spec/config_spec.rb +79 -0
  155. data/vendor/daemon-kit/spec/configurable_spec.rb +56 -0
  156. data/vendor/daemon-kit/spec/daemon_kit_spec.rb +7 -0
  157. data/vendor/daemon-kit/spec/error_handlers_spec.rb +23 -0
  158. data/vendor/daemon-kit/spec/fixtures/env.yml +15 -0
  159. data/vendor/daemon-kit/spec/fixtures/noenv.yml +4 -0
  160. data/vendor/daemon-kit/spec/initializer_spec.rb +26 -0
  161. data/vendor/daemon-kit/spec/spec.opts +1 -0
  162. data/vendor/daemon-kit/spec/spec_helper.rb +27 -0
  163. data/vendor/daemon-kit/tasks/rspec.rake +21 -0
  164. data/vendor/daemon-kit/templates/god/god.erb +69 -0
  165. data/vendor/daemon-kit/templates/monit/monit.erb +14 -0
  166. data/vendor/daemon-kit/test/test_amqp_generator.rb +48 -0
  167. data/vendor/daemon-kit/test/test_cron_generator.rb +45 -0
  168. data/vendor/daemon-kit/test/test_daemon-kit_generator.rb +84 -0
  169. data/vendor/daemon-kit/test/test_daemon_kit_config.rb +28 -0
  170. data/vendor/daemon-kit/test/test_deploy_capistrano_generator.rb +48 -0
  171. data/vendor/daemon-kit/test/test_generator_helper.rb +29 -0
  172. data/vendor/daemon-kit/test/test_helper.rb +7 -0
  173. data/vendor/daemon-kit/test/test_jabber_generator.rb +49 -0
  174. data/vendor/daemon-kit/test/test_nanite_agent_generator.rb +49 -0
  175. data/vendor/daemon-kit/test/test_ruote_generator.rb +45 -0
  176. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail.rb +5 -0
  177. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/address.rb +426 -0
  178. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/attachments.rb +46 -0
  179. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/base64.rb +46 -0
  180. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/compat.rb +41 -0
  181. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/config.rb +67 -0
  182. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/core_extensions.rb +63 -0
  183. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/encode.rb +581 -0
  184. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/header.rb +960 -0
  185. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/index.rb +9 -0
  186. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/interface.rb +1130 -0
  187. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/loader.rb +3 -0
  188. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mail.rb +578 -0
  189. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mailbox.rb +495 -0
  190. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/main.rb +6 -0
  191. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mbox.rb +3 -0
  192. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/net.rb +248 -0
  193. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/obsolete.rb +132 -0
  194. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/parser.rb +1476 -0
  195. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/port.rb +379 -0
  196. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/quoting.rb +118 -0
  197. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/require_arch.rb +58 -0
  198. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/scanner.rb +49 -0
  199. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/scanner_r.rb +261 -0
  200. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/stringio.rb +280 -0
  201. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/utils.rb +337 -0
  202. data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/version.rb +39 -0
  203. data/vendor/daemon-kit/vendor/tmail.rb +13 -0
  204. metadata +281 -0
@@ -0,0 +1,92 @@
1
+ = Logging from inside your daemon
2
+
3
+ Proper logging inside your daemon process is critical, and daemon-kit
4
+ provides you with a great logging facility to (ab)use.
5
+
6
+ == Logging examples
7
+
8
+ From anywhere in your code you can access the
9
+ <em>DaemonKit.logger</em> instance, which is a configured
10
+ DaemonKit::AbstractLogger. It is compatible with Ruby's Logger class
11
+ but is much more verbose to help you gain some insight into your
12
+ running process.
13
+
14
+ DaemonKit.logger.info( "Hello world" )
15
+
16
+ This logs a 'Hello world' line to the log file, complete with the
17
+ calling file name and line number. Log lines look something like this:
18
+
19
+ 2009-06-07 23:21:30.248575 capd(32513) [INFO] initializer.rb:91: DaemonKit (0.1.7.4) booted, now running capd
20
+
21
+ Log as much as you can, but be careful not to abuse the <em>info</em>
22
+ level since your log files can become huge. For general processing
23
+ hints, use the <em>debug</em> level.
24
+
25
+ To log exceptions, use the special <em>exception</em> helper:
26
+
27
+ begin
28
+ # dangerous operation
29
+ rescue => e
30
+ DaemonKit.logger.exception( e )
31
+ end
32
+
33
+ == Controlling logging in a running process
34
+
35
+ Logging can be controlled in a running process, either via code or by
36
+ sending UNIX signals to the running process.
37
+
38
+ === Changing log levels in your code
39
+
40
+ Log levels can be toggled with the <em>level=</em> method:
41
+
42
+ DaemonKit.logger.level = :info
43
+
44
+ Alternatively you can silence all the logging activity for a while
45
+ using the silence helper:
46
+
47
+ DaemonKit.logger.silence do |logger|
48
+ # logger will only report :error or higher levels
49
+ end
50
+
51
+ === Changing log levels via UNIX signals
52
+
53
+ Send your process the +USR1+ signal to toggle between <em>:debug</em>
54
+ and <em>:info</em> log levels. Sending a +USR2+ signal will force the
55
+ logger into <em>:debug</em> mode (+USR1+ will revert).
56
+
57
+ == Support for log rotation
58
+
59
+ Support for logrotate is baked right into daemon-kit. By sending your
60
+ daemon a +HUP+ signal all the log files file be closed and re-opened
61
+ again on first use. Here is an example logrotate configuration:
62
+
63
+ /path/to/daemon.log {
64
+ rotate 5
65
+ weekly
66
+ postrotate
67
+ kill -HUP `cat /path/to/daemon.pid`
68
+ endscript
69
+ }
70
+
71
+ == Support for syslog logging
72
+
73
+ If you have the
74
+ SyslogLogger[http://seattlerb.rubyforge.org/SyslogLogger/] gem
75
+ installed, you can have your process log to a UNIX syslog server. You
76
+ can change the logging to syslog by either updating your
77
+ <em>environment.rb</em> file like this:
78
+
79
+ config.log_path = :syslog
80
+
81
+ Or by passing 'syslog' as the logfile argument when starting a daemon
82
+
83
+ $ ruby ./bin/daemon start -l syslog
84
+
85
+ The SyslogLogger rdoc's provide configuration examples for configuring
86
+ various UNIX syslog servers.
87
+
88
+ == More logging information
89
+
90
+ If you're running your daemon in the foreground (with the <em>run</em>
91
+ command, you'll get copies of all the log messages on STDOUT, and thus
92
+ voiding the need to tail log files the whole time.
@@ -0,0 +1,166 @@
1
+ Configuration.txt
2
+ Deployment.txt
3
+ History.txt
4
+ Logging.txt
5
+ Manifest.txt
6
+ PostInstall.txt
7
+ README.rdoc
8
+ Rakefile
9
+ RuoteParticipants.txt
10
+ TODO.txt
11
+ app_generators/daemon_kit/USAGE
12
+ app_generators/daemon_kit/daemon_kit_generator.rb
13
+ app_generators/daemon_kit/templates/README
14
+ app_generators/daemon_kit/templates/Rakefile
15
+ app_generators/daemon_kit/templates/bin/daemon.erb
16
+ app_generators/daemon_kit/templates/config/arguments.rb
17
+ app_generators/daemon_kit/templates/config/boot.rb
18
+ app_generators/daemon_kit/templates/config/environment.rb
19
+ app_generators/daemon_kit/templates/config/environments/development.rb
20
+ app_generators/daemon_kit/templates/config/environments/production.rb
21
+ app_generators/daemon_kit/templates/config/environments/test.rb
22
+ app_generators/daemon_kit/templates/config/post-daemonize/readme
23
+ app_generators/daemon_kit/templates/config/pre-daemonize/readme
24
+ app_generators/daemon_kit/templates/lib/daemon.rb
25
+ app_generators/daemon_kit/templates/libexec/daemon.erb
26
+ app_generators/daemon_kit/templates/script/console
27
+ app_generators/daemon_kit/templates/script/destroy
28
+ app_generators/daemon_kit/templates/script/generate
29
+ bin/daemon_kit
30
+ daemon_generators/amqp/USAGE
31
+ daemon_generators/amqp/amqp_generator.rb
32
+ daemon_generators/amqp/templates/config/amqp.yml
33
+ daemon_generators/amqp/templates/config/initializers/amqp.rb
34
+ daemon_generators/amqp/templates/libexec/daemon.rb
35
+ daemon_generators/cron/USAGE
36
+ daemon_generators/cron/cron_generator.rb
37
+ daemon_generators/cron/templates/config/initializers/cron.rb
38
+ daemon_generators/cron/templates/libexec/daemon.rb
39
+ daemon_generators/cucumber/USAGE
40
+ daemon_generators/cucumber/cucumber_generator.rb
41
+ daemon_generators/cucumber/templates/cucumber
42
+ daemon_generators/cucumber/templates/cucumber.rake
43
+ daemon_generators/cucumber/templates/cucumber_environment.rb
44
+ daemon_generators/cucumber/templates/env.rb
45
+ daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb
46
+ daemon_generators/deploy_capistrano/templates/Capfile
47
+ daemon_generators/deploy_capistrano/templates/USAGE
48
+ daemon_generators/deploy_capistrano/templates/config/deploy.rb
49
+ daemon_generators/deploy_capistrano/templates/config/deploy/production.rb
50
+ daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb
51
+ daemon_generators/deploy_capistrano/templates/config/environments/staging.rb
52
+ daemon_generators/jabber/USAGE
53
+ daemon_generators/jabber/jabber_generator.rb
54
+ daemon_generators/jabber/templates/config/initializers/jabber.rb
55
+ daemon_generators/jabber/templates/config/jabber.yml
56
+ daemon_generators/jabber/templates/libexec/daemon.rb
57
+ daemon_generators/nanite_agent/USAGE
58
+ daemon_generators/nanite_agent/nanite_agent_generator.rb
59
+ daemon_generators/nanite_agent/templates/config/initializers/nanite_agent.rb
60
+ daemon_generators/nanite_agent/templates/config/nanite.yml
61
+ daemon_generators/nanite_agent/templates/lib/actors/sample.rb
62
+ daemon_generators/nanite_agent/templates/libexec/daemon.rb
63
+ daemon_generators/rspec/USAGE
64
+ daemon_generators/rspec/rspec_generator.rb
65
+ daemon_generators/rspec/templates/spec.rb
66
+ daemon_generators/rspec/templates/spec/spec.opts
67
+ daemon_generators/rspec/templates/spec/spec_helper.rb
68
+ daemon_generators/rspec/templates/tasks/rspec.rake
69
+ daemon_generators/ruote/USAGE
70
+ daemon_generators/ruote/ruote_generator.rb
71
+ daemon_generators/ruote/templates/config/amqp.yml
72
+ daemon_generators/ruote/templates/config/initializers/ruote.rb
73
+ daemon_generators/ruote/templates/config/ruote.yml
74
+ daemon_generators/ruote/templates/lib/daemon.rb
75
+ daemon_generators/ruote/templates/lib/sample.rb
76
+ daemon_generators/ruote/templates/libexec/daemon.rb
77
+ lib/daemon_kit.rb
78
+ lib/daemon_kit/abstract_logger.rb
79
+ lib/daemon_kit/amqp.rb
80
+ lib/daemon_kit/application.rb
81
+ lib/daemon_kit/arguments.rb
82
+ lib/daemon_kit/commands/console.rb
83
+ lib/daemon_kit/config.rb
84
+ lib/daemon_kit/console_daemon.rb
85
+ lib/daemon_kit/core_ext.rb
86
+ lib/daemon_kit/core_ext/configurable.rb
87
+ lib/daemon_kit/core_ext/string.rb
88
+ lib/daemon_kit/cron.rb
89
+ lib/daemon_kit/cucumber/world.rb
90
+ lib/daemon_kit/deployment/capistrano.rb
91
+ lib/daemon_kit/em.rb
92
+ lib/daemon_kit/error_handlers/base.rb
93
+ lib/daemon_kit/error_handlers/hoptoad.rb
94
+ lib/daemon_kit/error_handlers/mail.rb
95
+ lib/daemon_kit/exceptions.rb
96
+ lib/daemon_kit/initializer.rb
97
+ lib/daemon_kit/jabber.rb
98
+ lib/daemon_kit/nanite.rb
99
+ lib/daemon_kit/nanite/agent.rb
100
+ lib/daemon_kit/pid_file.rb
101
+ lib/daemon_kit/ruote_participants.rb
102
+ lib/daemon_kit/ruote_pseudo_participant.rb
103
+ lib/daemon_kit/ruote_workitem.rb
104
+ lib/daemon_kit/safety.rb
105
+ lib/daemon_kit/tasks.rb
106
+ lib/daemon_kit/tasks/environment.rake
107
+ lib/daemon_kit/tasks/framework.rake
108
+ lib/daemon_kit/tasks/god.rake
109
+ lib/daemon_kit/tasks/log.rake
110
+ lib/daemon_kit/tasks/monit.rake
111
+ script/console
112
+ script/destroy
113
+ script/generate
114
+ script/txt2html
115
+ spec/abstract_logger_spec.rb
116
+ spec/argument_spec.rb
117
+ spec/config_spec.rb
118
+ spec/configurable_spec.rb
119
+ spec/daemon_kit_spec.rb
120
+ spec/error_handlers_spec.rb
121
+ spec/fixtures/env.yml
122
+ spec/fixtures/noenv.yml
123
+ spec/initializer_spec.rb
124
+ spec/spec.opts
125
+ spec/spec_helper.rb
126
+ tasks/rspec.rake
127
+ templates/god/god.erb
128
+ templates/monit/monit.erb
129
+ test/test_amqp_generator.rb
130
+ test/test_cron_generator.rb
131
+ test/test_daemon-kit_generator.rb
132
+ test/test_daemon_kit_config.rb
133
+ test/test_deploy_capistrano_generator.rb
134
+ test/test_generator_helper.rb
135
+ test/test_helper.rb
136
+ test/test_jabber_generator.rb
137
+ test/test_nanite_agent_generator.rb
138
+ test/test_ruote_generator.rb
139
+ vendor/tmail-1.2.3/tmail.rb
140
+ vendor/tmail-1.2.3/tmail/address.rb
141
+ vendor/tmail-1.2.3/tmail/attachments.rb
142
+ vendor/tmail-1.2.3/tmail/base64.rb
143
+ vendor/tmail-1.2.3/tmail/compat.rb
144
+ vendor/tmail-1.2.3/tmail/config.rb
145
+ vendor/tmail-1.2.3/tmail/core_extensions.rb
146
+ vendor/tmail-1.2.3/tmail/encode.rb
147
+ vendor/tmail-1.2.3/tmail/header.rb
148
+ vendor/tmail-1.2.3/tmail/index.rb
149
+ vendor/tmail-1.2.3/tmail/interface.rb
150
+ vendor/tmail-1.2.3/tmail/loader.rb
151
+ vendor/tmail-1.2.3/tmail/mail.rb
152
+ vendor/tmail-1.2.3/tmail/mailbox.rb
153
+ vendor/tmail-1.2.3/tmail/main.rb
154
+ vendor/tmail-1.2.3/tmail/mbox.rb
155
+ vendor/tmail-1.2.3/tmail/net.rb
156
+ vendor/tmail-1.2.3/tmail/obsolete.rb
157
+ vendor/tmail-1.2.3/tmail/parser.rb
158
+ vendor/tmail-1.2.3/tmail/port.rb
159
+ vendor/tmail-1.2.3/tmail/quoting.rb
160
+ vendor/tmail-1.2.3/tmail/require_arch.rb
161
+ vendor/tmail-1.2.3/tmail/scanner.rb
162
+ vendor/tmail-1.2.3/tmail/scanner_r.rb
163
+ vendor/tmail-1.2.3/tmail/stringio.rb
164
+ vendor/tmail-1.2.3/tmail/utils.rb
165
+ vendor/tmail-1.2.3/tmail/version.rb
166
+ vendor/tmail.rb
@@ -0,0 +1,6 @@
1
+
2
+ For more information on daemon-kit, see http://kit.rubyforge.org/daemon-kit
3
+
4
+ To get started quickly run 'daemon_kit' without any arguments
5
+
6
+
@@ -0,0 +1,130 @@
1
+ = Daemon Kit
2
+
3
+ * http://kit.rubyforge.org/daemon-kit/rdoc/
4
+ * http://kit.rubyforge.org/daemon-kit (coming soon)
5
+ * http://groups.google.com/group/daemon-kit (daemon-kit@googlegroups.com)
6
+ * #daemon-kit on Freenode
7
+
8
+ == Description
9
+
10
+ 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.
11
+
12
+ Using simple built-in generators it is easy to created evented and non-evented daemons that perform a multitude of different tasks.
13
+
14
+ Supported generators:
15
+
16
+ * XMPP bot (non-evented)
17
+ * AMQP consumer (evented)
18
+ * Nanite agent
19
+ * Cron-style daemon
20
+ * ruote remote participants
21
+
22
+ == Features/Problems
23
+
24
+ * Build it
25
+ * Review TODO.txt
26
+
27
+ == Synopsis
28
+
29
+ $ daemon_kit -h
30
+
31
+ Get some help
32
+
33
+ $ daemon_kit [/path/to/your/daemon] [options]
34
+
35
+ The above command generates a skeleton daemon environment for you to adapt.
36
+
37
+ $ daemon_kit [/path/to/your/daemon] -i jabber
38
+
39
+ Use the 'jabber' generator instead of the default one.
40
+
41
+ == Generators
42
+
43
+ Currently six generators exist: default, jabber, amqp, cron, nanite & ruote
44
+
45
+ The default generator creates a simple daemon with an infinite loop inside that you can adapt.
46
+
47
+ === Jabber Generator
48
+
49
+ 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.
50
+
51
+ === Cron Generator
52
+
53
+ 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.
54
+
55
+ === AMQP Consumer Generator
56
+
57
+ 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.
58
+
59
+ === Nanite Agent Generator
60
+
61
+ The "nanite":http://github.com/ezmobius/nanite agent generator gets you up and running with nanite agents very quickly.
62
+
63
+ === ruote Remote Participants
64
+
65
+ The "ruote":http://openwfe.rubyforge.org remote participant generator speeds up the development of workflow participants that run outside of the Ruby process that houses the engine. Daemon-kit handles all the communication and delegation logic, allowing you to focus purely on your participant's activities.
66
+
67
+ == Requirements
68
+
69
+ * Ruby 1.8.6
70
+ * eventmachine-0.12.8[http://rubyeventmachine.com]
71
+ * rspec (for writing/running your specs)
72
+
73
+ == Generator Requirements
74
+
75
+ Depending on the generator you choose for your daemon, it might require additional gems to run.
76
+
77
+ * jabber - xmpp4r-simple[http://xmpp4r-simple.rubyforge.org]
78
+ * cron - rufus-scheduler[http://github.com/jmettraux/rufus-scheduler] (at least version 2.0.0)
79
+ * amqp - amqp[http://github.com/tmm1/amqp]
80
+ * nanite - nanite[http://github.com/ezmobius/nanite]
81
+ * ruote - none, although ruote[http://openwfe.rubyforge.org] should probably be running somewhere
82
+
83
+ == Install
84
+
85
+ Currently recommended to stick to the git repo:
86
+
87
+ $ git clone git://github.com/kennethkalmer/daemon-kit.git
88
+ $ rake gem
89
+ $ gem install pkg/daemon-kit-X.X.X.gem
90
+
91
+ Development versions are available as gems from github:
92
+
93
+ $ gem install kennethkalmer-daemon-kit -s http://gems.github.com
94
+
95
+ Stable versions, when released are available directly from Rubyforge:
96
+
97
+ $ gem install daemon-kit
98
+
99
+ == Further reading
100
+
101
+ * Configuration.txt
102
+ * Deployment.txt
103
+ * Logging.txt
104
+ * RuoteParticipants.txt
105
+ * http://www.opensourcery.co.za/tag/daemon-kit/
106
+
107
+ == License
108
+
109
+ (The MIT License)
110
+
111
+ Copyright (c) 2009 Kenneth Kalmer (Internet Exchange CC, Clear Planet Information Solutions Pty Ltd)
112
+
113
+ Permission is hereby granted, free of charge, to any person obtaining
114
+ a copy of this software and associated documentation files (the
115
+ 'Software'), to deal in the Software without restriction, including
116
+ without limitation the rights to use, copy, modify, merge, publish,
117
+ distribute, sublicense, and/or sell copies of the Software, and to
118
+ permit persons to whom the Software is furnished to do so, subject to
119
+ the following conditions:
120
+
121
+ The above copyright notice and this permission notice shall be
122
+ included in all copies or substantial portions of the Software.
123
+
124
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
125
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
126
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
127
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
128
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
129
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
130
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require File.dirname(__FILE__) + '/lib/daemon_kit'
6
+
7
+ Hoe.plugin :newgem
8
+ Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec('daemon-kit') do |p|
14
+ 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.'
15
+ p.developer('Kenneth Kalmer', 'kenneth.kalmer@gmail.com')
16
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
17
+ p.post_install_message = IO.read( 'PostInstall.txt' ) # TODO remove if post-install message not required
18
+ p.rubyforge_name = 'kit' # TODO this is default value
19
+ p.extra_deps = [
20
+ ['rubigen', '>= 1.5.2'],
21
+ ['eventmachine', '>=0.12.8']
22
+ ]
23
+ p.extra_dev_deps = [
24
+ ['newgem', ">= #{::Newgem::VERSION}"]
25
+ ]
26
+
27
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
28
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
29
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
30
+ p.rsync_args = '-av --delete --ignore-errors'
31
+ end
32
+
33
+ require 'newgem/tasks' # load /tasks/*.rake
34
+ Dir['tasks/**/*.rake'].each { |t| load t }
35
+
36
+ # TODO - want other tests/tasks run by default? Add them to the list
37
+ task :default => [:spec] #, :features]
@@ -0,0 +1,113 @@
1
+ = Writing remote ruote participants with daemon-kit
2
+
3
+ daemon-kit is an ideal housing for remote ruote participants, providing a lot
4
+ of convenience in terms of receiving and sending workitems, delegating work to
5
+ pseudo-participant classes, handling configuration of the communication channel
6
+ between ruote and the remote participant, and much more.
7
+
8
+ == What is ruote?
9
+
10
+ Ruote is a Ruby workflow engine. It is a powerful tool for defining, running and
11
+ orchestrating business processes.
12
+
13
+ * http://openwferu.rubyforge.org/
14
+ * http://www.opensourcery.co.za/2009/03/04/ruote-in-20-minutes/
15
+ * http://www.opensourcery.co.za/2009/07/06/driving-business-processes-in-ruby/
16
+
17
+ == What are remote participants?
18
+
19
+ Remote participants are participants that perform their work in a different
20
+ Ruby processes from the one running the engine. This is useful in two cases,
21
+ possibily many more, that involves autonomous participants.
22
+
23
+ * Autonomous participants located on remote servers, driven by identity
24
+ * Clustering autonomous participants to process workitems from a queue
25
+
26
+ To learn more about the differences between local and remote participants
27
+ please see http://openwferu.rubyforge.org/part.html
28
+
29
+ Currently on the AMQP components are in place in daemon-kit, with XMPP coming
30
+ soon.
31
+
32
+ == Creating a remote participant with daemon-kit
33
+
34
+ Generate your daemon using the 'ruote' generator:
35
+
36
+ $ daemon_kit partd -i ruote
37
+
38
+ Make sure you have the JSON gem install, and the AMQP gem as well.
39
+
40
+ == Configuring the daemon
41
+
42
+ You need to review +config/ruote.yml+ to specify the AMQP queues that the daemon
43
+ will subscribe to for receiving workitems. You'll also need to configure the
44
+ AMQP gem be updating +config/amqp.yml+
45
+
46
+ The generated daemon in +libexec/+ already defaults to using AMQP as a transport
47
+ for workitems.
48
+
49
+ == Writing pseudo-participants
50
+
51
+ Pseudo-participants in daemon-kit are pure Ruby classes. Implement your classes
52
+ in +lib/+ and require them from +lib/<daemon_name>.rb+.
53
+
54
+ Register your classes as pseudo-participants by registering them in the daemon
55
+ file in +libexec+, just as the Sample class is registered in the generated
56
+ code. Your class will be instantiated upon registration, and will be re-used
57
+ for every incoming workitem passed to it.
58
+
59
+ All your public methods in the pseudo-participant classes should be accept
60
+ a single parameter, which is a ruote workitem in pure Hash form.
61
+
62
+ == Wiring up the remote participant in ruote
63
+
64
+ See the complete code here: http://gist.github.com/144861
65
+
66
+ A sample process definition might look something like this:
67
+
68
+ class QuoteProcess < OpenWFE::ProcessDefinition
69
+ sequence do
70
+ kit :command => '/sample/quote', :queue => 'work1'
71
+
72
+ console
73
+ end
74
+ end
75
+
76
+ +kit+ in the above process definition is registered with the ruote engine as an
77
+ AMQPParticipant. The AMQPParticipant delivers workitems to the specified AMQP
78
+ queue.
79
+
80
+ Based on the values in +config/ruote.yml+, your daemon will be subscribed to
81
+ those queues.
82
+
83
+ The second part is delegating the workitem inside the daemon to the correct
84
+ pseudo-participant. This is handled by the +:command+ parameter in the process
85
+ definition. DaemonKit::Workitem looks at the command parameter of the incoming
86
+ workitem, and then finds a registered pseudo-participant instance and calls the
87
+ requested method on that class.
88
+
89
+ The +:command+ parameter follows the following convention (stolen shamelessly
90
+ from Nanite):
91
+
92
+ :command => '/class_name/method_name'
93
+
94
+ When classes are registered, the name of the class is downcased and camel-case
95
+ words are separated by underscores. Method names are not changed, but methods
96
+ are required to be public.
97
+
98
+ == Processing workitems and replying to the engine
99
+
100
+ The methods called in the pseudo-participants receive a single parameter, a
101
+ ruote workitem as a hash. The participant is then free to analyze the hash
102
+ and perform the appropriate actions required. The return value of the method
103
+ is discarded, and the workitem is returned back to the engine. If the method
104
+ modified the workitem, these changes will be sent along as well.
105
+
106
+ == Random other notes
107
+
108
+ Apart from configuring the AMPQ client (or XMPP in future) and the ruote.yml
109
+ file, daemon developers don't need to worry about anything related to receiving
110
+ workitems or sending replies.
111
+
112
+ Our aim is to allow you to swap between participants on both sides of the
113
+ transport without changing any of your code.