amqp-daemon-kit 0.1.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/.gitignore +5 -0
  2. data/Configuration.txt +110 -0
  3. data/Deployment.txt +113 -0
  4. data/History.txt +131 -0
  5. data/Logging.txt +96 -0
  6. data/PostInstall.txt +6 -0
  7. data/README.rdoc +132 -0
  8. data/Rakefile +29 -0
  9. data/RuoteParticipants.txt +113 -0
  10. data/TODO.txt +27 -0
  11. data/bin/daemon-kit +18 -0
  12. data/config/website.yml +2 -0
  13. data/daemon-kit.gemspec +265 -0
  14. data/lib/daemon_kit.rb +60 -0
  15. data/lib/daemon_kit/abstract_logger.rb +249 -0
  16. data/lib/daemon_kit/application.rb +230 -0
  17. data/lib/daemon_kit/arguments.rb +165 -0
  18. data/lib/daemon_kit/commands/console.rb +38 -0
  19. data/lib/daemon_kit/commands/destroy.rb +10 -0
  20. data/lib/daemon_kit/commands/generate.rb +10 -0
  21. data/lib/daemon_kit/config.rb +113 -0
  22. data/lib/daemon_kit/console_daemon.rb +2 -0
  23. data/lib/daemon_kit/core_ext.rb +1 -0
  24. data/lib/daemon_kit/core_ext/configurable.rb +96 -0
  25. data/lib/daemon_kit/core_ext/string.rb +22 -0
  26. data/lib/daemon_kit/cron.rb +67 -0
  27. data/lib/daemon_kit/cucumber/world.rb +38 -0
  28. data/lib/daemon_kit/deployment/capistrano.rb +516 -0
  29. data/lib/daemon_kit/dk_amqp.rb +39 -0
  30. data/lib/daemon_kit/em.rb +43 -0
  31. data/lib/daemon_kit/error_handlers/base.rb +32 -0
  32. data/lib/daemon_kit/error_handlers/hoptoad.rb +180 -0
  33. data/lib/daemon_kit/exceptions.rb +15 -0
  34. data/lib/daemon_kit/generators.rb +67 -0
  35. data/lib/daemon_kit/generators/base.rb +60 -0
  36. data/lib/daemon_kit/initializer.rb +449 -0
  37. data/lib/daemon_kit/jabber.rb +171 -0
  38. data/lib/daemon_kit/nanite.rb +7 -0
  39. data/lib/daemon_kit/nanite/agent.rb +77 -0
  40. data/lib/daemon_kit/pid_file.rb +61 -0
  41. data/lib/daemon_kit/ruote_participants.rb +125 -0
  42. data/lib/daemon_kit/ruote_pseudo_participant.rb +68 -0
  43. data/lib/daemon_kit/ruote_workitem.rb +187 -0
  44. data/lib/daemon_kit/safety.rb +84 -0
  45. data/lib/daemon_kit/tasks.rb +2 -0
  46. data/lib/daemon_kit/tasks/environment.rake +11 -0
  47. data/lib/daemon_kit/tasks/framework.rake +123 -0
  48. data/lib/daemon_kit/tasks/god.rake +62 -0
  49. data/lib/daemon_kit/tasks/log.rake +8 -0
  50. data/lib/daemon_kit/tasks/monit.rake +29 -0
  51. data/lib/daemon_kit/vendor/thor-0.13.6/CHANGELOG.rdoc +89 -0
  52. data/lib/daemon_kit/vendor/thor-0.13.6/LICENSE +20 -0
  53. data/lib/daemon_kit/vendor/thor-0.13.6/README.rdoc +297 -0
  54. data/lib/daemon_kit/vendor/thor-0.13.6/Thorfile +69 -0
  55. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor.rb +244 -0
  56. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions.rb +296 -0
  57. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/create_file.rb +103 -0
  58. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/directory.rb +91 -0
  59. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/empty_directory.rb +134 -0
  60. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/file_manipulation.rb +223 -0
  61. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/inject_into_file.rb +104 -0
  62. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/base.rb +540 -0
  63. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/core_ext/file_binary_read.rb +9 -0
  64. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  65. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/core_ext/ordered_hash.rb +100 -0
  66. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/error.rb +30 -0
  67. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/group.rb +271 -0
  68. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/invocation.rb +180 -0
  69. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser.rb +4 -0
  70. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/argument.rb +67 -0
  71. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/arguments.rb +150 -0
  72. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/option.rb +128 -0
  73. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/options.rb +169 -0
  74. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/rake_compat.rb +66 -0
  75. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/runner.rb +314 -0
  76. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell.rb +83 -0
  77. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell/basic.rb +239 -0
  78. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell/color.rb +108 -0
  79. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/task.rb +102 -0
  80. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/util.rb +224 -0
  81. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/version.rb +3 -0
  82. data/lib/daemon_kit/xmpp.rb +100 -0
  83. data/lib/generators/daemon_kit/amqp/USAGE +5 -0
  84. data/lib/generators/daemon_kit/amqp/amqp_generator.rb +24 -0
  85. data/lib/generators/daemon_kit/amqp/templates/config/amqp.yml +28 -0
  86. data/lib/generators/daemon_kit/amqp/templates/config/pre-daemonize/amqp.rb +7 -0
  87. data/lib/generators/daemon_kit/amqp/templates/libexec/%app_name%-daemon.rb +37 -0
  88. data/lib/generators/daemon_kit/app/USAGE +7 -0
  89. data/lib/generators/daemon_kit/app/app_generator.rb +140 -0
  90. data/lib/generators/daemon_kit/app/templates/Gemfile +12 -0
  91. data/lib/generators/daemon_kit/app/templates/README.tt +58 -0
  92. data/lib/generators/daemon_kit/app/templates/Rakefile +6 -0
  93. data/lib/generators/daemon_kit/app/templates/bin/daemon.tt +7 -0
  94. data/lib/generators/daemon_kit/app/templates/config/arguments.rb +12 -0
  95. data/lib/generators/daemon_kit/app/templates/config/boot.rb +70 -0
  96. data/lib/generators/daemon_kit/app/templates/config/environment.rb.tt +26 -0
  97. data/lib/generators/daemon_kit/app/templates/config/environments/development.rb +2 -0
  98. data/lib/generators/daemon_kit/app/templates/config/environments/production.rb +5 -0
  99. data/lib/generators/daemon_kit/app/templates/config/environments/test.rb +2 -0
  100. data/lib/generators/daemon_kit/app/templates/config/post-daemonize/readme +5 -0
  101. data/lib/generators/daemon_kit/app/templates/config/pre-daemonize/readme +12 -0
  102. data/lib/generators/daemon_kit/app/templates/lib/%app_name%.rb +2 -0
  103. data/lib/generators/daemon_kit/app/templates/libexec/%app_name%-daemon.rb +18 -0
  104. data/lib/generators/daemon_kit/app/templates/script/console +3 -0
  105. data/lib/generators/daemon_kit/app/templates/script/destroy +3 -0
  106. data/lib/generators/daemon_kit/app/templates/script/generate +3 -0
  107. data/lib/generators/daemon_kit/capistrano/capistrano_generator.rb +26 -0
  108. data/lib/generators/daemon_kit/capistrano/templates/Capfile +10 -0
  109. data/lib/generators/daemon_kit/capistrano/templates/USAGE +10 -0
  110. data/lib/generators/daemon_kit/capistrano/templates/config/deploy.rb.tt +67 -0
  111. data/lib/generators/daemon_kit/capistrano/templates/config/deploy/logrotate.erb +13 -0
  112. data/lib/generators/daemon_kit/capistrano/templates/config/deploy/production.rb.tt +6 -0
  113. data/lib/generators/daemon_kit/capistrano/templates/config/deploy/staging.rb.tt +6 -0
  114. data/lib/generators/daemon_kit/capistrano/templates/config/environments/staging.rb +0 -0
  115. data/lib/generators/daemon_kit/cron/USAGE +5 -0
  116. data/lib/generators/daemon_kit/cron/cron_generator.rb +24 -0
  117. data/lib/generators/daemon_kit/cron/templates/config/pre-daemonize/cron.rb +11 -0
  118. data/lib/generators/daemon_kit/cron/templates/libexec/%app_name%-daemon.rb +48 -0
  119. data/lib/generators/daemon_kit/cucumber/USAGE +11 -0
  120. data/lib/generators/daemon_kit/cucumber/cucumber_generator.rb +45 -0
  121. data/lib/generators/daemon_kit/cucumber/templates/config/environments/cucumber.rb +2 -0
  122. data/lib/generators/daemon_kit/cucumber/templates/features/step_definitions/.empty_directory +0 -0
  123. data/lib/generators/daemon_kit/cucumber/templates/features/support/env.rb +7 -0
  124. data/lib/generators/daemon_kit/cucumber/templates/script/cucumber +7 -0
  125. data/lib/generators/daemon_kit/cucumber/templates/tasks/cucumber.rake +13 -0
  126. data/lib/generators/daemon_kit/nanite_agent/USAGE +5 -0
  127. data/lib/generators/daemon_kit/nanite_agent/nanite_agent_generator.rb +29 -0
  128. data/lib/generators/daemon_kit/nanite_agent/templates/config/nanite.yml +35 -0
  129. data/lib/generators/daemon_kit/nanite_agent/templates/config/pre-daemonize/nanite_agent.rb +6 -0
  130. data/lib/generators/daemon_kit/nanite_agent/templates/lib/actors/sample.rb +11 -0
  131. data/lib/generators/daemon_kit/nanite_agent/templates/libexec/%app_name%-daemon.rb +31 -0
  132. data/lib/generators/daemon_kit/rspec/USAGE +5 -0
  133. data/lib/generators/daemon_kit/rspec/rspec_generator.rb +20 -0
  134. data/lib/generators/daemon_kit/rspec/templates/spec/%app_name%_spec.rb +11 -0
  135. data/lib/generators/daemon_kit/rspec/templates/spec/spec.opts +1 -0
  136. data/lib/generators/daemon_kit/rspec/templates/spec/spec_helper.rb +23 -0
  137. data/lib/generators/daemon_kit/rspec/templates/tasks/rspec.rake +21 -0
  138. data/lib/generators/daemon_kit/ruote/USAGE +5 -0
  139. data/lib/generators/daemon_kit/ruote/ruote_generator.rb +29 -0
  140. data/lib/generators/daemon_kit/ruote/templates/config/amqp.yml +30 -0
  141. data/lib/generators/daemon_kit/ruote/templates/config/pre-daemonize/ruote.rb +13 -0
  142. data/lib/generators/daemon_kit/ruote/templates/config/ruote.yml +23 -0
  143. data/lib/generators/daemon_kit/ruote/templates/lib/%app_name%.rb +4 -0
  144. data/lib/generators/daemon_kit/ruote/templates/lib/sample.rb +26 -0
  145. data/lib/generators/daemon_kit/ruote/templates/libexec/%app_name%-daemon.rb +33 -0
  146. data/lib/generators/daemon_kit/test_unit/USAGE +5 -0
  147. data/lib/generators/daemon_kit/test_unit/templates/tasks/test_unit.rake +7 -0
  148. data/lib/generators/daemon_kit/test_unit/templates/test/%app_name%_test.rb.tt +9 -0
  149. data/lib/generators/daemon_kit/test_unit/templates/test/test_helper.rb +6 -0
  150. data/lib/generators/daemon_kit/test_unit/test_unit_generator.rb +20 -0
  151. data/lib/generators/daemon_kit/xmpp/templates/config/pre-daemonize/xmpp.rb +6 -0
  152. data/lib/generators/daemon_kit/xmpp/templates/config/xmpp.yml +29 -0
  153. data/lib/generators/daemon_kit/xmpp/templates/libexec/%app_name%-daemon.rb +27 -0
  154. data/lib/generators/daemon_kit/xmpp/xmpp_generator.rb +24 -0
  155. data/script/console +10 -0
  156. data/script/destroy +14 -0
  157. data/script/generate +14 -0
  158. data/script/txt2html +71 -0
  159. data/spec/abstract_logger_spec.rb +126 -0
  160. data/spec/argument_spec.rb +70 -0
  161. data/spec/config_spec.rb +83 -0
  162. data/spec/configurable_spec.rb +56 -0
  163. data/spec/daemon_kit_spec.rb +7 -0
  164. data/spec/error_handlers_spec.rb +23 -0
  165. data/spec/fixtures/env.yml +15 -0
  166. data/spec/fixtures/noenv.yml +4 -0
  167. data/spec/initializer_spec.rb +26 -0
  168. data/spec/spec.opts +1 -0
  169. data/spec/spec_helper.rb +27 -0
  170. data/tasks/cucumber.rake +13 -0
  171. data/tasks/rspec.rake +20 -0
  172. data/tasks/tests.rake +6 -0
  173. data/templates/god/god.erb +69 -0
  174. data/templates/monit/monit.erb +14 -0
  175. data/test/test_amqp_generator.rb +48 -0
  176. data/test/test_cron_generator.rb +45 -0
  177. data/test/test_daemon-kit_generator.rb +84 -0
  178. data/test/test_daemon_kit_config.rb +28 -0
  179. data/test/test_deploy_capistrano_generator.rb +48 -0
  180. data/test/test_generator_helper.rb +29 -0
  181. data/test/test_helper.rb +7 -0
  182. data/test/test_nanite_agent_generator.rb +49 -0
  183. data/test/test_ruote_generator.rb +51 -0
  184. data/test/test_test_unit_generator.rb +46 -0
  185. metadata +302 -0
@@ -0,0 +1,5 @@
1
+ *#*
2
+ pkg/
3
+ tmp/
4
+ doc/
5
+ *.swp
@@ -0,0 +1,110 @@
1
+ = Configuring your daemon
2
+
3
+ daemon-kit provides a multitude of ways to configure your daemon, this document
4
+ will outline the different options available to you.
5
+
6
+ == Configuration files and #DaemonKit::Config
7
+
8
+ #DaemonKit::Config gives you easy access to any YAML configuration
9
+ files you have in your <em>config</em> directory.
10
+
11
+ You can access the configuration files like this:
12
+
13
+ config = DaemonKit::Config.load('sample')
14
+
15
+ The above snippet relies on the presence of a <em>config/sample.yml</em> file.
16
+
17
+ #DaemonKit::Config is environment aware, so configuration files are
18
+ parsed for a top-level key that is the same as the value of
19
+ <em>DAEMON_ENV</em>, and if present is loaded into the object as the
20
+ configuration data. If the key is not present, the whole YAML
21
+ document is exposed as configuration data.
22
+
23
+ == Command line arguments
24
+
25
+ The most flexible way to configure your daemon is through command line
26
+ arguments, or switches.
27
+
28
+ DaemonKit includes a couple of its own arguments that can be used:
29
+
30
+ -e ENV (or --env ENV) to set the daemon environment
31
+ --pid /path/to/pidfile to set the path to a pidfile
32
+ -l path (or --log path) to set the path for the log file
33
+ -v shows the DaemonKit version
34
+ -h shows a useful help message
35
+
36
+ === Custom arguments
37
+
38
+ It is possible for you to specify your own arguments as well, by
39
+ updating the <em>config/arguments.rb</em> file. This file is eval'd
40
+ inside #DaemonKit::Arguments and gives you access to the following two
41
+ variables:
42
+
43
+ * opts - Instance of OptionParser[http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html]
44
+ * @options - A standard Ruby hash that you can populate and access later
45
+
46
+ Your custom arguments can be accessed like this:
47
+
48
+ DaemonKit.arguments.options
49
+
50
+ === Advanced Configuration
51
+
52
+ All the writable attributes of the default #DaemonKit::Configuration
53
+ instance call also be modified from the command line using the special
54
+ <em>--config</em> arguments:
55
+
56
+ --config force_kill_wait=30
57
+
58
+ This happens after <em>config/environment.rb</em> is processed, so all
59
+ command line arguments will overwrite those values.
60
+
61
+ === Daemon umask
62
+
63
+ By default daemon processes run with a umask of 022, but this can be changed
64
+ on the command line or in +config/environment.rb+.
65
+
66
+ To set a more restrictive umask via command line arguments, you can start your
67
+ daemon like this:
68
+
69
+ $ ./bin/daemon start --config umask=0077
70
+
71
+ Or the same in +config/environment.rb+
72
+
73
+ DaemonKit::Initializer.run do |config|
74
+ # ...
75
+
76
+ # restrictive umask
77
+ config.umask = 0077
78
+
79
+ # ...
80
+ end
81
+
82
+ === Privilege Separation
83
+
84
+ By default daemon processes run as the user that starts them, inheriting all
85
+ their privileges (or lack thereof). Getting daemon-kit to drop privileges
86
+ can currently only be done using command-line parameters, and only works
87
+ reliable on *nix (OSX seemed cranky at the time of testing).
88
+
89
+ $ ./bin/daemon start --config user=nobody --config group=nobody
90
+
91
+ Privileges are dropped at the earliest possible phase of starting the daemon.
92
+
93
+ Things to note on privilege separation:
94
+
95
+ * You generally have to be root to be able to perform this
96
+ * File system permissions for +log/+ needs to be correct
97
+ * Daemon-kit will only shed privileges on the +start+ command, not on +run+
98
+ * Make sure your code is secure if accepting stuff from the outside world
99
+ * The daemon will continue to run if it failed, this is because the feature is experimental and could change in the future.
100
+ * The damon logs the reduced privileges in the log file shortly after booting, please check it carefully
101
+
102
+ The implementation stems from the advice given by Joe Damato on his blog post
103
+ http://timetobleed.com/tag/privilege-escalation/
104
+
105
+ IMPORTANT NOTE FOR OSX USERS:
106
+
107
+ Testing on my iBook with OSX 10.5.8 using Ruby 1.8.6-p287 failed to drop
108
+ privileges correctly because of the 'nobody' user's UID being too large
109
+ (Bignum), however testing with Ruby 1.9.1-p129 on OSX 10.5.8 did work as
110
+ expected.
@@ -0,0 +1,113 @@
1
+ = Deploying your daemons
2
+
3
+ daemon-kit provides built-in support for
4
+ Capistrano[http://www.capify.org] deployments, using a customized
5
+ version of the standard 'deploy' recipe for Ruby on Rails
6
+ applications.
7
+
8
+ User of Vlad[http://hitsquad.rubyforge.org/vlad/]? Get in touch so we
9
+ can discuss your contribution to daemon-kit ;)
10
+
11
+ == Generating capistrano configurations
12
+
13
+ When generating a new daemon, you can pass the <em>-d capistrano</em>
14
+ argument to the <em>daemon_kit</em> command. In case you already have
15
+ a generated daemon, run the following command inside your project:
16
+
17
+ $ ruby script/generate deploy_capistrano
18
+
19
+ == Overview of generated configurations
20
+
21
+ The generator creates the following files worth noticing:
22
+
23
+ config/deploy.rb
24
+ config/deploy/*.rb
25
+
26
+ The generator also creates a new environment for you, a
27
+ <em>staging</em> environment. Useful for testing your deployments
28
+ before taking anything into production.
29
+
30
+ == Configuring capistrano
31
+
32
+ For each environment (staging & production) you only need to specify
33
+ the target hosts in <em>config/deploy/(staging|production).rb</em>.
34
+
35
+ Each of the stub files have example configuration values you can just
36
+ edit.
37
+
38
+ The rest of your configuration generally occurs in
39
+ <em>config/deploy.rb</em>.
40
+
41
+ Everything works exactly like standard capistrano, with the exception
42
+ of the following directives:
43
+
44
+ * :config_files
45
+ * :shared_children
46
+
47
+ === :config_files
48
+
49
+ Since the daemon configuration files will almost always differ between
50
+ your development environment and your staging/production environment,
51
+ the deployment recipe makes adequate provision for this.
52
+
53
+ Use the :config_files directive to set an array of file names from the
54
+ <em>config</em> directory that you want replaced with production
55
+ configuration files found on the server:
56
+
57
+ set :config_files, %w{ amqp.yaml }
58
+
59
+ On your target server, in the <em>:deploy_to</em> folder, create a
60
+ <em>config</em> directory and place your configuration files in
61
+ there. One each deploy, capistrano will rename the files in your
62
+ deployed configuration directory with a <em>.orig</em> extension, and copy
63
+ the files from <em>:deploy_to/config</em> into the newly deployed
64
+ release.
65
+
66
+ This makes it easy to keep production configurations out of your
67
+ working directories or version control systems.
68
+
69
+ === :shared_children
70
+
71
+ The original capistrano recipe that daemon-kit's recipe is built from
72
+ provided support for tracking shared directories between
73
+ deployments. This works by removing the deployed directory, and
74
+ creating a symlink from <em>:deploy_to/shared/</em> into the correct
75
+ location within the deployed release.
76
+
77
+ You specify your list of directories with the
78
+ <em>:shared_children</em>, each being relative to the DAEMON_ROOT.
79
+
80
+ set :shared_children, %w{ log }
81
+
82
+ The daemon-kit deployment recipe makes no assumptions on shared
83
+ directories, and gives you full control. The default only includes the
84
+ log directory, which you can remove if you want separate log
85
+ directories for each deployed release.
86
+
87
+ == Remote dependencies
88
+
89
+ By default, the deployment configuration file is configured to check
90
+ the remote dependencies before updating the code on the target
91
+ host. You can disable this behaviour by commenting out the following
92
+ line:
93
+
94
+ before "deploy:update_code", "deploy:check"
95
+
96
+ The only default remote dependency is the daemon-kit gem, and it will
97
+ check for the same version you currently have installed (or a later
98
+ one).
99
+
100
+ == More capistrano resources
101
+
102
+ To see a list of available commands, please run the following command
103
+ in the root of your project:
104
+
105
+ $ cap -vT
106
+
107
+ For more information on capistrano, please refer to the following list
108
+ of online resources:
109
+
110
+ * Capistrano Website[http://www.capify.org]
111
+ * Capistrano Wiki[http://wiki.capify.org]
112
+ * Capistrano Group[http://groups.google.com/group/capistrano]
113
+ * #capistrano on Freenode
@@ -0,0 +1,131 @@
1
+ == 0.1.18.1 2010-08-04
2
+
3
+ * Fixed issue with our own amqp.rb file causing havoc on Ruby 1.8.7
4
+
5
+ == 0.1.18 2010-08-03
6
+
7
+ * Generators rewritten to use Thor
8
+ * Evented XMPP now handled by blather
9
+ * Boot script fixes
10
+ * Removed Jabber generator, deprecating Jabber class (use XMPP)
11
+ * Upgraded Hoptoad notifications to V2 of the notifier API
12
+ * Fix various argument handling bugs
13
+ * Removed support for exception emails
14
+ * Improved log rotation support [mperham]
15
+ * Initial 1.9.2 support
16
+ * Exception handling for scheduled tasks (cron)
17
+ * Updates for ruote-amqp versions 2.1 and later
18
+
19
+ == 0.1.7.12 2009-12-04
20
+
21
+ * Bug fix, don't load environment files twice [grockit]
22
+
23
+ == 0.1.7.11 2009-11-30
24
+
25
+ * Renamed 'daemon_kit' executable to 'daemon-kit'
26
+ * Fixed some broken links in README.rdoc
27
+ * Sneaked in << on AbstractLogger for better Logger compatibility
28
+ * Support for Test::Unit in generated projects [skaar]
29
+ * Fixed missing DAEMON_ENV for test helpers
30
+ * Fixes for nanite configuration [skaar]
31
+ * Toughened up the ruote workitem parser
32
+ * Fixed issue with nanite services not being advertised correctly [Wijnand]
33
+ * Fixed some woes with rake if rspec gem is missing
34
+
35
+ == 0.1.7.10 2009-08-12
36
+
37
+ * Ruote remote participants
38
+ * Allow process umask to be configured, defaults to 022
39
+ * Updates to DaemonKit::Config hashes
40
+ * Fixed argument parsing bug (reported by Mathijs Kwik (bluescreen303)
41
+ * Support for privilege separation (See Configuration.txt)
42
+
43
+ == 0.1.7.9 2009-06-22
44
+
45
+ * Backtraces only logged on unclean shutdown
46
+ * AMQP generator got new keep alive code
47
+
48
+ == 0.1.7.8 2009-06-22
49
+
50
+ * Optional logging of all exceptions when the daemon process dies
51
+ unexpectedly
52
+ * Update generated environment.rb to reflect new backtraces option
53
+
54
+ == 0.1.7.7 2009-06-22
55
+
56
+ * Fixed compatibility with rufus-scheduler-2.0.0 (or newer) in cron
57
+ generator
58
+ * Started central eventmachine reactor management code
59
+ * Now depends on eventmachine
60
+
61
+ == 0.1.7.6 (Not released)
62
+
63
+ * Support for cucumber
64
+ * Fixed issue in daemon_kit:upgrade task
65
+ * Moved rspec generator into new home
66
+ * Removed conflicting rubigen generator, messed with our script directory
67
+ * Fixed bug where environment.rb overwrites some --config values (reported by Josh Owens)
68
+
69
+ == 0.1.7.5 2009-06-08
70
+
71
+ * New AbstractLogger
72
+ ** Default Logger backend
73
+ ** SysLogLogger support
74
+ * More documentation
75
+
76
+ == 0.1.7.4 2009-06-05
77
+
78
+ * Fixed bug with control script generator (thanks Sho Fukamachi)
79
+ * Enhanced deploy.rb template to check for current dk gem verion,
80
+ unless vendored
81
+ * Fix bug in capistrano recipe for restarting daemons
82
+ * Added log:truncate rake task
83
+ * Error mails now handled by TMail
84
+
85
+ == 0.1.7.3 2009-05-31
86
+
87
+ * Removed dependency on daemons gem, now handled in house
88
+ * New argument management
89
+ * Some more docs
90
+
91
+ == 0.1.7.1 2009-05-28
92
+
93
+ * Fixed some minor issue with Capistrano support
94
+ * Added support for generating dog/monit configuration files via rake
95
+ * Initial implementation of ./script/* utilities
96
+
97
+ == 0.1.7 2009-05-26
98
+
99
+ * Capistrano deployment support
100
+
101
+ == 0.1.6 2009-05-13
102
+
103
+ * DaemonKit::Safety class to handle the trapping and logging of
104
+ exceptions, as well as email notifications or Hoptoad notifications.
105
+ * New config/pre-daemonize and config/post-daemonize structure
106
+ * New tasks to simplify upgrading daemon-kit projects
107
+ * Fixed some other annoyances and bugs
108
+ * Bigger TODO list
109
+
110
+ == 0.1.5 2009-05-07
111
+
112
+ * DaemonKit::Config class to easy the use of YAML configs internally,
113
+ and in generated daemons
114
+
115
+ == 0.1.2 2009-04-28
116
+
117
+ * Added missing rubigen dependency
118
+
119
+ == 0.1.1 2009-04-27
120
+
121
+ * AMQP consumer generator added
122
+ * 'cron' style generator added
123
+ * Allow configuring dir_mode and dir (pid file location) (Jim Lindley)
124
+
125
+ == 0.1.0 2009-01-08
126
+
127
+ * Ability to freeze the gem/edge copies of DaemonKit
128
+ * Simple non-evented Jabber generator
129
+ * Flexible UNIX signal trapping configuration
130
+ * Basic generator completed
131
+ * 1 small step for man, 1 giant leap for mankind
@@ -0,0 +1,96 @@
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
+ You can also set the logging per environment by editing the correct file in <em>config/environments</em>
52
+
53
+ config.log_level = :debug
54
+
55
+ === Changing log levels via UNIX signals
56
+
57
+ Send your process the +USR1+ signal to toggle between <em>:debug</em>
58
+ and <em>:info</em> log levels. Sending a +USR2+ signal will force the
59
+ logger into <em>:debug</em> mode (+USR1+ will revert).
60
+
61
+ == Support for log rotation
62
+
63
+ Support for logrotate is baked right into daemon-kit. By sending your
64
+ daemon a +HUP+ signal all the log files file be closed and re-opened
65
+ again on first use. Here is an example logrotate configuration:
66
+
67
+ /path/to/daemon.log {
68
+ rotate 5
69
+ weekly
70
+ postrotate
71
+ kill -HUP `cat /path/to/daemon.pid`
72
+ endscript
73
+ }
74
+
75
+ == Support for syslog logging
76
+
77
+ If you have the
78
+ SyslogLogger[http://seattlerb.rubyforge.org/SyslogLogger/] gem
79
+ installed, you can have your process log to a UNIX syslog server. You
80
+ can change the logging to syslog by either updating your
81
+ <em>environment.rb</em> file like this:
82
+
83
+ config.log_path = :syslog
84
+
85
+ Or by passing 'syslog' as the logfile argument when starting a daemon
86
+
87
+ $ ruby ./bin/daemon start -l syslog
88
+
89
+ The SyslogLogger rdoc's provide configuration examples for configuring
90
+ various UNIX syslog servers.
91
+
92
+ == More logging information
93
+
94
+ If you're running your daemon in the foreground (with the <em>run</em>
95
+ command, you'll get copies of all the log messages on STDOUT, and thus
96
+ voiding the need to tail log files the whole time.