dosire-god 0.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. data/History.txt +261 -0
  2. data/Manifest.txt +107 -0
  3. data/README.txt +59 -0
  4. data/Rakefile +35 -0
  5. data/bin/god +127 -0
  6. data/examples/events.god +84 -0
  7. data/examples/gravatar.god +54 -0
  8. data/examples/single.god +66 -0
  9. data/ext/god/extconf.rb +55 -0
  10. data/ext/god/kqueue_handler.c +123 -0
  11. data/ext/god/netlink_handler.c +167 -0
  12. data/init/god +42 -0
  13. data/lib/god/behavior.rb +52 -0
  14. data/lib/god/behaviors/clean_pid_file.rb +21 -0
  15. data/lib/god/behaviors/clean_unix_socket.rb +21 -0
  16. data/lib/god/behaviors/notify_when_flapping.rb +51 -0
  17. data/lib/god/cli/command.rb +206 -0
  18. data/lib/god/cli/run.rb +177 -0
  19. data/lib/god/cli/version.rb +23 -0
  20. data/lib/god/condition.rb +96 -0
  21. data/lib/god/conditions/always.rb +23 -0
  22. data/lib/god/conditions/complex.rb +86 -0
  23. data/lib/god/conditions/cpu_usage.rb +80 -0
  24. data/lib/god/conditions/degrading_lambda.rb +52 -0
  25. data/lib/god/conditions/disk_usage.rb +27 -0
  26. data/lib/god/conditions/flapping.rb +128 -0
  27. data/lib/god/conditions/http_response_code.rb +168 -0
  28. data/lib/god/conditions/lambda.rb +25 -0
  29. data/lib/god/conditions/memory_usage.rb +82 -0
  30. data/lib/god/conditions/process_exits.rb +72 -0
  31. data/lib/god/conditions/process_running.rb +74 -0
  32. data/lib/god/conditions/tries.rb +44 -0
  33. data/lib/god/configurable.rb +57 -0
  34. data/lib/god/contact.rb +106 -0
  35. data/lib/god/contacts/email.rb +95 -0
  36. data/lib/god/dependency_graph.rb +41 -0
  37. data/lib/god/diagnostics.rb +37 -0
  38. data/lib/god/driver.rb +206 -0
  39. data/lib/god/errors.rb +24 -0
  40. data/lib/god/event_handler.rb +111 -0
  41. data/lib/god/event_handlers/dummy_handler.rb +13 -0
  42. data/lib/god/event_handlers/kqueue_handler.rb +17 -0
  43. data/lib/god/event_handlers/netlink_handler.rb +13 -0
  44. data/lib/god/logger.rb +120 -0
  45. data/lib/god/metric.rb +59 -0
  46. data/lib/god/process.rb +327 -0
  47. data/lib/god/registry.rb +32 -0
  48. data/lib/god/simple_logger.rb +53 -0
  49. data/lib/god/socket.rb +96 -0
  50. data/lib/god/sugar.rb +47 -0
  51. data/lib/god/system/portable_poller.rb +42 -0
  52. data/lib/god/system/process.rb +42 -0
  53. data/lib/god/system/slash_proc_poller.rb +82 -0
  54. data/lib/god/task.rb +487 -0
  55. data/lib/god/timeline.rb +25 -0
  56. data/lib/god/trigger.rb +43 -0
  57. data/lib/god/watch.rb +183 -0
  58. data/lib/god.rb +644 -0
  59. data/test/configs/child_events/child_events.god +44 -0
  60. data/test/configs/child_events/simple_server.rb +3 -0
  61. data/test/configs/child_polls/child_polls.god +37 -0
  62. data/test/configs/child_polls/simple_server.rb +12 -0
  63. data/test/configs/complex/complex.god +59 -0
  64. data/test/configs/complex/simple_server.rb +3 -0
  65. data/test/configs/contact/contact.god +74 -0
  66. data/test/configs/contact/simple_server.rb +3 -0
  67. data/test/configs/daemon_events/daemon_events.god +37 -0
  68. data/test/configs/daemon_events/simple_server.rb +8 -0
  69. data/test/configs/daemon_events/simple_server_stop.rb +11 -0
  70. data/test/configs/daemon_polls/daemon_polls.god +17 -0
  71. data/test/configs/daemon_polls/simple_server.rb +6 -0
  72. data/test/configs/degrading_lambda/degrading_lambda.god +31 -0
  73. data/test/configs/degrading_lambda/tcp_server.rb +15 -0
  74. data/test/configs/matias/matias.god +50 -0
  75. data/test/configs/real.rb +59 -0
  76. data/test/configs/running_load/running_load.god +16 -0
  77. data/test/configs/stress/simple_server.rb +3 -0
  78. data/test/configs/stress/stress.god +15 -0
  79. data/test/configs/task/logs/.placeholder +0 -0
  80. data/test/configs/task/task.god +26 -0
  81. data/test/configs/test.rb +61 -0
  82. data/test/helper.rb +151 -0
  83. data/test/suite.rb +6 -0
  84. data/test/test_behavior.rb +21 -0
  85. data/test/test_condition.rb +50 -0
  86. data/test/test_conditions_disk_usage.rb +56 -0
  87. data/test/test_conditions_http_response_code.rb +109 -0
  88. data/test/test_conditions_process_running.rb +44 -0
  89. data/test/test_conditions_tries.rb +67 -0
  90. data/test/test_contact.rb +109 -0
  91. data/test/test_dependency_graph.rb +62 -0
  92. data/test/test_driver.rb +11 -0
  93. data/test/test_event_handler.rb +80 -0
  94. data/test/test_god.rb +598 -0
  95. data/test/test_handlers_kqueue_handler.rb +16 -0
  96. data/test/test_logger.rb +63 -0
  97. data/test/test_metric.rb +72 -0
  98. data/test/test_process.rb +246 -0
  99. data/test/test_registry.rb +15 -0
  100. data/test/test_socket.rb +42 -0
  101. data/test/test_sugar.rb +42 -0
  102. data/test/test_system_portable_poller.rb +17 -0
  103. data/test/test_system_process.rb +30 -0
  104. data/test/test_task.rb +262 -0
  105. data/test/test_timeline.rb +37 -0
  106. data/test/test_trigger.rb +59 -0
  107. data/test/test_watch.rb +279 -0
  108. metadata +186 -0
data/History.txt ADDED
@@ -0,0 +1,261 @@
1
+ == 0.7.9 / 2008-08-06
2
+ * Major Enhancements
3
+ * Use a psuedo-priority queue for more efficient driver loop [Darrell Kresge]
4
+ * Bug Fixes
5
+ * Fix file_writable? when using chroot [github.com/eric]
6
+
7
+ == 0.7.8 / 2008-07-09
8
+ * Bug Fixes
9
+ * Catch all Exceptions from HttpResponseCode condition [github.com/rliebling]
10
+ * Don't error out if the process went away in SlashProcPoller [Kevin Clark]
11
+ * Correction of Task#handle_poll to prevent crash under event registration failure conditions. [github.com/raggi]
12
+ * Cleaned up logging of failed e-mail sends. [github.com/raggi]
13
+ * Listen on 127.0.0.1 when using God as a client. [github.com/halorgium]
14
+ * New Behaviors
15
+ * clean_unix_socket [github.com/gma]
16
+ * New Contacts
17
+ * jabber [github.com/jwulff]
18
+ * email via sendmail [github.com/monde]
19
+ * Minor Enhancements
20
+ * chroot support [github.com/eric]
21
+ * Added God.log_file for the main god log, overridden by command line option. [github.com/raggi]
22
+ * Print groups from `god status` command if present [github.com/pdlug]
23
+ * Allow headers to be specified for http_response_code condition [github.com/pdlug]
24
+
25
+ == 0.7.7 / 2008-06-17
26
+ * Bug Fixes
27
+ * Fix detection of proc file system [raggi]
28
+
29
+ == 0.7.6 / 2008-05-13
30
+ * Major Enhancements
31
+ * Implement System::Process methods for Linux based on /proc [Kevin Clark]
32
+ * Minor Enhancements
33
+ * Allowing directories to be loaded at start [Bert Goethals]
34
+ * Bug Fixes
35
+ * Don't leak events on error in the kqueue handler [Kevin Clark]
36
+
37
+ == 0.7.5 / 2008-02-21
38
+ * Bug Fixes
39
+ * Remove Ruby's Logger and replace with custom SimpleLogger to stop threaded leak
40
+
41
+ == 0.7.4 / 2008-02-18
42
+ * Bug Fixes
43
+ * Introduce local scope to prevent faulty optimization that causes memory to leak
44
+
45
+ == 0.7.3 / 2008-02-14
46
+ * Minor Enhancements
47
+ * Add --bleakhouse to make running diagnostics easier
48
+ * Bug Fixes
49
+ * Use ::Process.kill(0, ...) instead of `kill -0` [queso]
50
+ * Fix pid_file behavior in process-centric conditions so they work with tasks [matias]
51
+ * Redirect output of daemonized god to log file or /dev/null earlier [_eric]
52
+
53
+ == 0.7.2 / 2008-02-04
54
+ * Bug Fixes
55
+ * Start event system for CLI commands
56
+ * Up internal history to 100 lines per watch
57
+
58
+ == 0.7.1 / 2008-02-04
59
+ * Minor Enhancements
60
+ * Add --no-events option to completely disable events system
61
+
62
+ == 0.7.0 / 2008-02-01
63
+ * Minor Enhancements
64
+ * Better default pid_file_directory behavior
65
+ * Add --attach <pid> to specify that god should quit if <pid> exits
66
+ * Bug Fixes
67
+ * Handle ECONNRESET in HttpResponseCode
68
+
69
+ == 0.6.12 / 2008-01-31
70
+ * Minor Enhancements
71
+ * Allow log file output for non-daemonized god
72
+ * Switch to SIGTERM from SIGHUP for default lambda killer
73
+
74
+ == 0.6.11 / 2008-01-31
75
+ * Major Enhancements
76
+ * HUGE refactor of timer system to simplify scheduling
77
+ * Minor Enhancements
78
+ * Check for a truly working event system and disallow event conditions if none is present
79
+
80
+ == 0.6.10 / 2008-01-24
81
+ * Bug Fixes
82
+ * Fix ensure_stop nil pid no local variable bug
83
+
84
+ == 0.6.9 / 2008-01-23
85
+ * Bug Fixes
86
+ * Fix Timer condition dedup behavior
87
+
88
+ == 0.6.8 / 2008-01-23
89
+ * Minor Enhancements
90
+ * Warn if a command returns a non-zero exit code
91
+ * Ensure that stop command actually stops process
92
+
93
+ == 0.6.7 / 2008-01-22
94
+ * Minor Enhancements
95
+ * Add --no-syslog option to disable Syslog
96
+ * Allow contact redeclaration (dups are ignored)
97
+
98
+ == 0.6.6 / 2008-01-07
99
+ * Bug Fixes
100
+ * Redo Timer mutexing to reduce synchronization needs
101
+
102
+ == 0.6.5 / 2008-01-04
103
+ * Bug Fixes
104
+ * Fix Timer descheduling deadlock issue
105
+ * Change HttpResponseCode to use GET instead of HEAD
106
+
107
+ == 0.6.4 / 2008-12-31
108
+ * Bug Fixes
109
+ * Refactor Hub to clarify mutexing
110
+ * Eliminate potential iteration problem in Timer
111
+ * Add caching PID accessor to process to solve event deregistration failure
112
+
113
+ == 0.6.3 / 2007-12-18
114
+ * Minor Enhancements
115
+ * Output ProcessExits registration/deregistration info
116
+
117
+ == 0.6.2 / 2007-12-17
118
+ * Minor Enhancements
119
+ * Output registered PID for ProcessExits
120
+ * Bug Fixes
121
+ * Fix `god remove <group>` not working for unmonitored watches
122
+
123
+ == 0.6.1 / 2007-12-14
124
+
125
+ * Minor Enhancement
126
+ * Log when state change is complete
127
+
128
+ == 0.6.0 / 2007-12-4
129
+
130
+ * Minor Enhancement
131
+ * Move Syslog calls into God::Logger and clean up all calling code
132
+ * Remove god's pid file on user requested termination
133
+ * Better handling and cleanup of DRb server's unix domain socket
134
+ * Allow shorthand for requesting a god log
135
+ * Add `god check` to make it easier to diagnose event problems
136
+ * Refactor god binary into class/method structure
137
+ * Implement `god remove` to remove a Task altogether
138
+ * New Conditions
139
+ * DiskUsage < PollCondition - trigger if disk usage is above limit on mount [Rudy Desjardins]
140
+
141
+ == 0.5.2 / 2007-10-10
142
+
143
+ * Minor Enhancement
144
+ * Allow extra args to pass through to config file
145
+
146
+ == 0.5.1 / 2007-10-08
147
+
148
+ * Bug Fixes
149
+ * Rescue connection refused in http response code condition
150
+
151
+ == 0.5.0 / 2007-10-05
152
+
153
+ * Major Enhancements
154
+ * Implement lifecycle scoped metric to allow for cross-state conditions
155
+ * Add TriggerCondition for conditions that need info about state changes
156
+ * Implement notification system
157
+ * Add Tasks (a generalization of Watches) to do non-process related tasks
158
+ * Add example init.d file in GOD_INSTALL_DIR/init/god [scott becker]
159
+ * Add human readable info to conditions (and make low level log lines debug)
160
+ * Switch DRb to use a unix domain socket for security reasons
161
+ * Minor Enchancements
162
+ * Allow EventConditions to do transition overloading
163
+ * Report errors during god startup instead of failing silently
164
+ * Make transition block optional (default to Always condition returning true)
165
+ * Better usage info for `god --help`
166
+ * Explain what's going on when attempting to rebind to an in-use port
167
+ * Add -b option to god binary to auto-bind to an unused port
168
+ * Add `god quit` to stop god without stopping any tasks
169
+ * Make self-daemonized Watch commands synchronous (as they should be)
170
+ * Allow self-daemonized Watches to specify a log (could be useful)
171
+ * Check for existence of config file if specified
172
+ * Robustify `god load` and report errors back to the command issuer
173
+ * Warn when `god load` tries to set global options
174
+ * Add Configurable.clear method and make built-in conditions clear on entry
175
+ * New Conditions
176
+ * Flapping < TriggerCondition - trigger on state change
177
+ * HttpResponseCode < PollCondition - trigger on http response code or timeout (thx scott becker)
178
+ * New Contacts
179
+ * Email < Contact - notify via email (smtp)
180
+ * Bug Fixes
181
+ * Fix abort not aborting problem
182
+ * Fix -p option not working for god binary
183
+ * Fix God.init not accepting block (thx _eric)
184
+ * Fix SIGHUP ignore (thx _eric)
185
+ * Fix error reporting on `god --help` (don't error report a normal SystemExit)
186
+
187
+ == 0.4.3 / 2007-09-10
188
+ * Bug Fixes
189
+ * fix Process#alive? to not raise on no such file (affects `god terminate`)
190
+
191
+ == 0.4.2 / 2007-09-10
192
+ * Bug Fixes
193
+ * fix netlink buffer issue that prevented events on Linux from working consistently [dkresge]
194
+
195
+ == 0.4.1 / 2007-09-10
196
+ * Bug Fixes
197
+ * require 'stringio' for ruby 1.8.5
198
+
199
+ == 0.4.0 / 2007-09-10
200
+
201
+ * Major Enhancements
202
+ * Add the ability for conditions to override transition state (for exceptional cases)
203
+ * Implement dynamic load of config files while god is running (god load <filename>)
204
+ * Add ability to save auto-daemonized process output to a log file
205
+ * Add robust default stop lambda command for auto-daemonized processes (inspired by _eric)
206
+ * Add status command for god binary (shows status of each watch)
207
+ * Create proper logger with timestamps
208
+ * Add log command to god binary to get real time logs for a specific watch from a running god instance
209
+ * Add terminate command for god binary (stop god and all watches)
210
+ * Minor Enhancements
211
+ * Enforce validity of Watches
212
+ * Enforce that God.init is not called after a Watch
213
+ * Move pid_file_directory creation and validation to God.start
214
+ * Remove check for at least one Watch during startup (now that dynamic loading exists)
215
+ * New Conditions
216
+ * Tries < PollCondition - triggers after the specified number of tries
217
+ * Add :notify_when_flapping behavior to check for oscillation [kevinclark]
218
+ * Add :degrading_lambda condition. [kevinclark]
219
+ It uses a decaying interval (1/2 rate) for 3 cycles before failing.
220
+ * Bug Fixes
221
+ * Use exit!(0) instead of exit! in god binary to exit with code 0 (instead of default -1)
222
+ * Command line group control fixed
223
+ * Fix cross-thread return problem
224
+
225
+ == 0.3.0 / 2007-08-17
226
+
227
+ * Fix netlink header problem on Ubuntu Edgy [Dan Sully]
228
+ * Add uid/gid setting for processes [kevinclark]
229
+ * Add autostart flag for watches so they don't necessarily startup with god [kevinclark]
230
+ * Change command line call options for god binary to accommodate watch start/stop functionality
231
+ * Add individual start/stop/restart grace periods for finer grained control
232
+ * Change default DRb port to 17165 ('god'.to_i(32))
233
+ * Implement command line control to start/restart/stop/monitor/unmonitor watches/groups by name
234
+ * Watches can now belong to a group that can be controlled as a whole
235
+ * Allow god to be installed (sans events) on systems that don't support events
236
+ * Daemonize and handle PID files for non-daemonizing scripts [kevinclark]
237
+ * Fix simple mode lifecycle gap
238
+ * Remove necessity to specify pid_file for conditions
239
+ * Change config file to use God.init and God.watch directly instead of God.meddle block
240
+ * Move god binary command logic to main library
241
+ * Enhance god binary with better reporting
242
+ * Fix synchronization bug in Timer (reported by Srini Panguluri)
243
+ * Add Lambda condition for easy custom conditions [Mike Mintz]
244
+ * Add sugar for numerics (seconds, minutes, kilobytes, megabytes, percent, etc)
245
+ * Add optional PID and log file generation to god binary for daemon mode
246
+ * Add God.load to do glob enabled loading
247
+ * Add -V option to god binary for detailed version/build info
248
+
249
+ == 0.2.0 / 2007-07-18
250
+
251
+ * Rewrote innards to use a state and event based lifecycle
252
+ * Basic support for events via kqueue (bsd/darwin) and netlink/pec (linux) [kevinclark]
253
+ * Added advanced syntax (simple syntax calls advanced api underneath)
254
+ * Condition returns have changed meaning. With simple syntax, a true return activates block
255
+ * Updated http://god.rubyforge.org with updated simple config and new advanced config
256
+
257
+ == 0.1.0 / 2007-07-07
258
+
259
+ * 1 major enhancement
260
+ * Birthday!
261
+
data/Manifest.txt ADDED
@@ -0,0 +1,107 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/god
6
+ examples/events.god
7
+ examples/gravatar.god
8
+ examples/single.god
9
+ ext/god/extconf.rb
10
+ ext/god/kqueue_handler.c
11
+ ext/god/netlink_handler.c
12
+ init/god
13
+ lib/god.rb
14
+ lib/god/behavior.rb
15
+ lib/god/behaviors/clean_pid_file.rb
16
+ lib/god/behaviors/clean_unix_socket.rb
17
+ lib/god/behaviors/notify_when_flapping.rb
18
+ lib/god/cli/command.rb
19
+ lib/god/cli/run.rb
20
+ lib/god/cli/version.rb
21
+ lib/god/condition.rb
22
+ lib/god/conditions/always.rb
23
+ lib/god/conditions/complex.rb
24
+ lib/god/conditions/cpu_usage.rb
25
+ lib/god/conditions/degrading_lambda.rb
26
+ lib/god/conditions/disk_usage.rb
27
+ lib/god/conditions/flapping.rb
28
+ lib/god/conditions/http_response_code.rb
29
+ lib/god/conditions/lambda.rb
30
+ lib/god/conditions/memory_usage.rb
31
+ lib/god/conditions/process_exits.rb
32
+ lib/god/conditions/process_running.rb
33
+ lib/god/conditions/tries.rb
34
+ lib/god/configurable.rb
35
+ lib/god/contact.rb
36
+ lib/god/contacts/email.rb
37
+ lib/god/dependency_graph.rb
38
+ lib/god/diagnostics.rb
39
+ lib/god/driver.rb
40
+ lib/god/errors.rb
41
+ lib/god/event_handler.rb
42
+ lib/god/event_handlers/dummy_handler.rb
43
+ lib/god/event_handlers/kqueue_handler.rb
44
+ lib/god/event_handlers/netlink_handler.rb
45
+ lib/god/logger.rb
46
+ lib/god/metric.rb
47
+ lib/god/process.rb
48
+ lib/god/registry.rb
49
+ lib/god/simple_logger.rb
50
+ lib/god/socket.rb
51
+ lib/god/sugar.rb
52
+ lib/god/system/portable_poller.rb
53
+ lib/god/system/process.rb
54
+ lib/god/system/slash_proc_poller.rb
55
+ lib/god/task.rb
56
+ lib/god/timeline.rb
57
+ lib/god/trigger.rb
58
+ lib/god/watch.rb
59
+ test/configs/child_events/child_events.god
60
+ test/configs/child_events/simple_server.rb
61
+ test/configs/child_polls/child_polls.god
62
+ test/configs/child_polls/simple_server.rb
63
+ test/configs/complex/complex.god
64
+ test/configs/complex/simple_server.rb
65
+ test/configs/contact/contact.god
66
+ test/configs/contact/simple_server.rb
67
+ test/configs/daemon_events/daemon_events.god
68
+ test/configs/daemon_events/simple_server.rb
69
+ test/configs/daemon_events/simple_server_stop.rb
70
+ test/configs/daemon_polls/daemon_polls.god
71
+ test/configs/daemon_polls/simple_server.rb
72
+ test/configs/degrading_lambda/degrading_lambda.god
73
+ test/configs/degrading_lambda/tcp_server.rb
74
+ test/configs/matias/matias.god
75
+ test/configs/real.rb
76
+ test/configs/running_load/running_load.god
77
+ test/configs/stress/simple_server.rb
78
+ test/configs/stress/stress.god
79
+ test/configs/task/logs/.placeholder
80
+ test/configs/task/task.god
81
+ test/configs/test.rb
82
+ test/helper.rb
83
+ test/suite.rb
84
+ test/test_behavior.rb
85
+ test/test_condition.rb
86
+ test/test_conditions_disk_usage.rb
87
+ test/test_conditions_http_response_code.rb
88
+ test/test_conditions_process_running.rb
89
+ test/test_conditions_tries.rb
90
+ test/test_contact.rb
91
+ test/test_dependency_graph.rb
92
+ test/test_driver.rb
93
+ test/test_event_handler.rb
94
+ test/test_god.rb
95
+ test/test_handlers_kqueue_handler.rb
96
+ test/test_logger.rb
97
+ test/test_metric.rb
98
+ test/test_process.rb
99
+ test/test_registry.rb
100
+ test/test_socket.rb
101
+ test/test_sugar.rb
102
+ test/test_system_portable_poller.rb
103
+ test/test_system_process.rb
104
+ test/test_task.rb
105
+ test/test_timeline.rb
106
+ test/test_trigger.rb
107
+ test/test_watch.rb
data/README.txt ADDED
@@ -0,0 +1,59 @@
1
+ god
2
+ by Tom Preston-Werner
3
+ Kevin Clark (kqueue/netlink support)
4
+
5
+ http://god.rubyforge.org
6
+
7
+ == DESCRIPTION:
8
+
9
+ God is an easy to configure, easy to extend monitoring framework written
10
+ in Ruby.
11
+
12
+ Keeping your server processes and tasks running should be a simple part of
13
+ your deployment process. God aims to be the simplest, most powerful
14
+ monitoring application available.
15
+
16
+ == DOCUMENTATION:
17
+
18
+ See online documentation at http://god.rubyforge.org
19
+
20
+ == COMMUNITY:
21
+
22
+ Sign up for the god mailing list at http://groups.google.com/group/god-rb
23
+
24
+ == INSTALL:
25
+
26
+ $ sudo gem install god
27
+
28
+ == CONTRIBUTE:
29
+
30
+ Latest code is available at http://github.com/mojombo/god
31
+
32
+ The 'master' branch can be cloned with:
33
+
34
+ $ git clone git://github.com/mojombo/god.git
35
+
36
+ == LICENSE:
37
+
38
+ (The MIT License)
39
+
40
+ Copyright (c) 2007 Tom Preston-Werner
41
+
42
+ Permission is hereby granted, free of charge, to any person obtaining
43
+ a copy of this software and associated documentation files (the
44
+ 'Software'), to deal in the Software without restriction, including
45
+ without limitation the rights to use, copy, modify, merge, publish,
46
+ distribute, sublicense, and/or sell copies of the Software, and to
47
+ permit persons to whom the Software is furnished to do so, subject to
48
+ the following conditions:
49
+
50
+ The above copyright notice and this permission notice shall be
51
+ included in all copies or substantial portions of the Software.
52
+
53
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
54
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
55
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
56
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
57
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
58
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
59
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'hoe'
3
+
4
+ Hoe.new('god', '0.7.9') do |p|
5
+ p.rubyforge_name = 'god'
6
+ p.author = 'Tom Preston-Werner'
7
+ p.email = 'tom@rubyisawesome.com'
8
+ p.url = 'http://god.rubyforge.org/'
9
+ p.summary = 'Like monit, only awesome'
10
+ p.description = "God is an easy to configure, easy to extend monitoring framework written in Ruby."
11
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
12
+ p.spec_extras = {:extensions => ['ext/god/extconf.rb']}
13
+ end
14
+
15
+ desc "Open an irb session preloaded with this library"
16
+ task :console do
17
+ sh "irb -rubygems -r ./lib/god.rb"
18
+ end
19
+
20
+ desc "Upload site to Rubyforge"
21
+ task :site do
22
+ sh "scp -r site/* mojombo@god.rubyforge.org:/var/www/gforge-projects/god"
23
+ end
24
+
25
+ desc "Upload site to Rubyforge"
26
+ task :site_edge do
27
+ sh "scp -r site/* mojombo@god.rubyforge.org:/var/www/gforge-projects/god/edge"
28
+ end
29
+
30
+ desc "Run rcov"
31
+ task :coverage do
32
+ `rm -fr coverage`
33
+ `rcov test/test_*.rb`
34
+ `open coverage/index.html`
35
+ end
data/bin/god ADDED
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ STDOUT.sync = true
4
+
5
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
6
+
7
+ require 'rubygems'
8
+ require 'optparse'
9
+ require 'drb'
10
+
11
+ begin
12
+ options = {:daemonize => true, :port => 17165, :syslog => true, :events => true}
13
+
14
+ opts = OptionParser.new do |opts|
15
+ opts.banner = <<-EOF
16
+ Usage:
17
+ Starting:
18
+ god [-c <config file>] [-p <port> | -b] [-P <file>] [-l <file>] [-D]
19
+
20
+ Querying:
21
+ god <command> <argument> [-p <port>]
22
+ god <command> [-p <port>]
23
+ god -v
24
+ god -V (must be run as root to be accurate on Linux)
25
+
26
+ Commands:
27
+ start <task or group name> start task or group
28
+ restart <task or group name> restart task or group
29
+ stop <task or group name> stop task or group
30
+ monitor <task or group name> monitor task or group
31
+ unmonitor <task or group name> unmonitor task or group
32
+ remove <task or group name> remove task or group from god
33
+ load <file> load a config into a running god
34
+ log <task name> show realtime log for given task
35
+ status show status of each task
36
+ quit stop god
37
+ terminate stop god and all tasks
38
+ check run self diagnostic
39
+
40
+ Options:
41
+ EOF
42
+
43
+ opts.on("-cCONFIG", "--config-file CONFIG", "Configuration file") do |x|
44
+ options[:config] = x
45
+ end
46
+
47
+ opts.on("-pPORT", "--port PORT", "Communications port (default 17165)") do |x|
48
+ options[:port] = x
49
+ end
50
+
51
+ opts.on("-b", "--auto-bind", "Auto-bind to an unused port number") do
52
+ options[:port] = "0"
53
+ end
54
+
55
+ opts.on("-PFILE", "--pid FILE", "Where to write the PID file") do |x|
56
+ options[:pid] = x
57
+ end
58
+
59
+ opts.on("-lFILE", "--log FILE", "Where to write the log file") do |x|
60
+ options[:log] = x
61
+ end
62
+
63
+ opts.on("-D", "--no-daemonize", "Don't daemonize") do
64
+ options[:daemonize] = false
65
+ end
66
+
67
+ opts.on("-v", "--version", "Print the version number and exit") do
68
+ options[:version] = true
69
+ end
70
+
71
+ opts.on("-V", "Print extended version and build information") do
72
+ options[:info] = true
73
+ end
74
+
75
+ opts.on("--log-level LEVEL", "Log level [debug|info|warn|error|fatal]") do |x|
76
+ options[:log_level] = x.to_sym
77
+ end
78
+
79
+ opts.on("--no-syslog", "Disable output to syslog") do
80
+ options[:syslog] = false
81
+ end
82
+
83
+ opts.on("--attach PID", "Quit god when the attached process dies") do |x|
84
+ options[:attach] = x
85
+ end
86
+
87
+ opts.on("--no-events", "Disable the event system") do
88
+ options[:events] = false
89
+ end
90
+
91
+ opts.on("--bleakhouse", "Enable bleakhouse profiling") do
92
+ options[:bleakhouse] = true
93
+ end
94
+ end
95
+
96
+ opts.parse!
97
+
98
+ # validate
99
+ if options[:log_level] && ![:debug, :info, :warn, :error, :fatal].include?(options[:log_level])
100
+ abort("Invalid log level '#{options[:log_level]}'")
101
+ end
102
+
103
+ # dispatch
104
+ if !options[:config] && options[:version]
105
+ require 'god'
106
+ God::CLI::Version.version
107
+ elsif !options[:config] && options[:info]
108
+ require 'god'
109
+ God::EventHandler.load
110
+ God::CLI::Version.version_extended
111
+ elsif !options[:config] && command = ARGV[0]
112
+ require 'god'
113
+ God::EventHandler.load
114
+ God::CLI::Command.new(command, options, ARGV)
115
+ else
116
+ require 'god/cli/run'
117
+ God::CLI::Run.new(options)
118
+ end
119
+ rescue Exception => e
120
+ if e.instance_of?(SystemExit)
121
+ raise
122
+ else
123
+ puts 'Uncaught exception'
124
+ puts e.message
125
+ puts e.backtrace.join("\n")
126
+ end
127
+ end
@@ -0,0 +1,84 @@
1
+ # This example shows how you might keep a local development Rails server up
2
+ # and running on your Mac.
3
+
4
+ # Run with:
5
+ # god -c /path/to/events.god
6
+
7
+ RAILS_ROOT = ENV['GOD_TEST_RAILS_ROOT']
8
+
9
+ %w{3002}.each do |port|
10
+ God.watch do |w|
11
+ w.name = "local-#{port}"
12
+ w.interval = 5.seconds
13
+ w.start = "mongrel_rails start -p #{port} -P #{RAILS_ROOT}/log/mongrel.#{port}.pid -c #{RAILS_ROOT} -d"
14
+ w.stop = "mongrel_rails stop -P #{RAILS_ROOT}/log/mongrel.#{port}.pid -c #{RAILS_ROOT}"
15
+ w.pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid")
16
+ w.log = File.join(RAILS_ROOT, "log/commands.#{port}.log")
17
+
18
+ # clean pid files before start if necessary
19
+ w.behavior(:clean_pid_file)
20
+
21
+ # determine the state on startup
22
+ w.transition(:init, { true => :up, false => :start }) do |on|
23
+ on.condition(:process_running) do |c|
24
+ c.running = true
25
+ end
26
+ end
27
+
28
+ # determine when process has finished starting
29
+ w.transition([:start, :restart], :up) do |on|
30
+ on.condition(:process_running) do |c|
31
+ c.running = true
32
+ end
33
+
34
+ # failsafe
35
+ on.condition(:tries) do |c|
36
+ c.times = 8
37
+ c.within = 2.minutes
38
+ c.transition = :start
39
+ end
40
+ end
41
+
42
+ # start if process is not running
43
+ w.transition(:up, :start) do |on|
44
+ on.condition(:process_exits)
45
+ end
46
+
47
+ # restart if memory or cpu is too high
48
+ w.transition(:up, :restart) do |on|
49
+ on.condition(:memory_usage) do |c|
50
+ c.interval = 20
51
+ c.above = 50.megabytes
52
+ c.times = [3, 5]
53
+ end
54
+
55
+ on.condition(:cpu_usage) do |c|
56
+ c.interval = 10
57
+ c.above = 10.percent
58
+ c.times = 5
59
+ end
60
+
61
+ on.condition(:http_response_code) do |c|
62
+ c.host = 'localhost'
63
+ c.port = port
64
+ c.path = '/'
65
+ c.code_is = 500
66
+ c.timeout = 10.seconds
67
+ c.times = [3, 5]
68
+ end
69
+ end
70
+
71
+ # lifecycle
72
+ w.lifecycle do |on|
73
+ on.condition(:flapping) do |c|
74
+ c.to_state = [:start, :restart]
75
+ c.times = 5
76
+ c.within = 1.minute
77
+ c.transition = :unmonitored
78
+ c.retry_in = 10.minutes
79
+ c.retry_times = 5
80
+ c.retry_within = 2.hours
81
+ end
82
+ end
83
+ end
84
+ end