resurrected_god 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/Announce.txt +135 -0
  3. data/Gemfile +5 -0
  4. data/LICENSE +22 -0
  5. data/README.md +33 -0
  6. data/Rakefile +129 -0
  7. data/bin/god +134 -0
  8. data/doc/god.asciidoc +1592 -0
  9. data/doc/intro.asciidoc +20 -0
  10. data/ext/god/.gitignore +5 -0
  11. data/ext/god/extconf.rb +56 -0
  12. data/ext/god/kqueue_handler.c +133 -0
  13. data/ext/god/netlink_handler.c +182 -0
  14. data/lib/god/behavior.rb +52 -0
  15. data/lib/god/behaviors/clean_pid_file.rb +21 -0
  16. data/lib/god/behaviors/clean_unix_socket.rb +21 -0
  17. data/lib/god/behaviors/notify_when_flapping.rb +51 -0
  18. data/lib/god/cli/command.rb +268 -0
  19. data/lib/god/cli/run.rb +170 -0
  20. data/lib/god/cli/version.rb +23 -0
  21. data/lib/god/compat19.rb +33 -0
  22. data/lib/god/condition.rb +96 -0
  23. data/lib/god/conditions/always.rb +36 -0
  24. data/lib/god/conditions/complex.rb +86 -0
  25. data/lib/god/conditions/cpu_usage.rb +80 -0
  26. data/lib/god/conditions/degrading_lambda.rb +52 -0
  27. data/lib/god/conditions/disk_usage.rb +32 -0
  28. data/lib/god/conditions/file_mtime.rb +28 -0
  29. data/lib/god/conditions/file_touched.rb +44 -0
  30. data/lib/god/conditions/flapping.rb +128 -0
  31. data/lib/god/conditions/http_response_code.rb +184 -0
  32. data/lib/god/conditions/lambda.rb +25 -0
  33. data/lib/god/conditions/memory_usage.rb +82 -0
  34. data/lib/god/conditions/process_exits.rb +66 -0
  35. data/lib/god/conditions/process_running.rb +63 -0
  36. data/lib/god/conditions/socket_responding.rb +142 -0
  37. data/lib/god/conditions/tries.rb +44 -0
  38. data/lib/god/configurable.rb +57 -0
  39. data/lib/god/contact.rb +114 -0
  40. data/lib/god/contacts/airbrake.rb +44 -0
  41. data/lib/god/contacts/campfire.rb +121 -0
  42. data/lib/god/contacts/email.rb +130 -0
  43. data/lib/god/contacts/hipchat.rb +117 -0
  44. data/lib/god/contacts/jabber.rb +75 -0
  45. data/lib/god/contacts/prowl.rb +57 -0
  46. data/lib/god/contacts/scout.rb +55 -0
  47. data/lib/god/contacts/sensu.rb +59 -0
  48. data/lib/god/contacts/slack.rb +98 -0
  49. data/lib/god/contacts/statsd.rb +46 -0
  50. data/lib/god/contacts/twitter.rb +51 -0
  51. data/lib/god/contacts/webhook.rb +74 -0
  52. data/lib/god/driver.rb +238 -0
  53. data/lib/god/errors.rb +24 -0
  54. data/lib/god/event_handler.rb +112 -0
  55. data/lib/god/event_handlers/dummy_handler.rb +13 -0
  56. data/lib/god/event_handlers/kqueue_handler.rb +17 -0
  57. data/lib/god/event_handlers/netlink_handler.rb +13 -0
  58. data/lib/god/logger.rb +109 -0
  59. data/lib/god/metric.rb +87 -0
  60. data/lib/god/process.rb +381 -0
  61. data/lib/god/registry.rb +32 -0
  62. data/lib/god/simple_logger.rb +59 -0
  63. data/lib/god/socket.rb +113 -0
  64. data/lib/god/sugar.rb +62 -0
  65. data/lib/god/sys_logger.rb +45 -0
  66. data/lib/god/system/portable_poller.rb +42 -0
  67. data/lib/god/system/process.rb +50 -0
  68. data/lib/god/system/slash_proc_poller.rb +92 -0
  69. data/lib/god/task.rb +552 -0
  70. data/lib/god/timeline.rb +25 -0
  71. data/lib/god/trigger.rb +43 -0
  72. data/lib/god/version.rb +4 -0
  73. data/lib/god/watch.rb +340 -0
  74. data/lib/god.rb +777 -0
  75. data/test/configs/child_events/child_events.god +44 -0
  76. data/test/configs/child_events/simple_server.rb +3 -0
  77. data/test/configs/child_polls/child_polls.god +37 -0
  78. data/test/configs/child_polls/simple_server.rb +12 -0
  79. data/test/configs/complex/complex.god +59 -0
  80. data/test/configs/complex/simple_server.rb +3 -0
  81. data/test/configs/contact/contact.god +118 -0
  82. data/test/configs/contact/simple_server.rb +3 -0
  83. data/test/configs/daemon_events/daemon_events.god +37 -0
  84. data/test/configs/daemon_events/simple_server.rb +8 -0
  85. data/test/configs/daemon_events/simple_server_stop.rb +11 -0
  86. data/test/configs/daemon_polls/daemon_polls.god +17 -0
  87. data/test/configs/daemon_polls/simple_server.rb +6 -0
  88. data/test/configs/degrading_lambda/degrading_lambda.god +31 -0
  89. data/test/configs/degrading_lambda/tcp_server.rb +15 -0
  90. data/test/configs/keepalive/keepalive.god +9 -0
  91. data/test/configs/keepalive/keepalive.rb +12 -0
  92. data/test/configs/lifecycle/lifecycle.god +25 -0
  93. data/test/configs/matias/matias.god +50 -0
  94. data/test/configs/real.rb +59 -0
  95. data/test/configs/running_load/running_load.god +16 -0
  96. data/test/configs/stop_options/simple_server.rb +12 -0
  97. data/test/configs/stop_options/stop_options.god +39 -0
  98. data/test/configs/stress/simple_server.rb +3 -0
  99. data/test/configs/stress/stress.god +15 -0
  100. data/test/configs/task/logs/.placeholder +0 -0
  101. data/test/configs/task/task.god +26 -0
  102. data/test/configs/test.rb +61 -0
  103. data/test/configs/usr1_trapper.rb +10 -0
  104. data/test/helper.rb +172 -0
  105. data/test/suite.rb +6 -0
  106. data/test/test_airbrake.rb +14 -0
  107. data/test/test_behavior.rb +18 -0
  108. data/test/test_campfire.rb +22 -0
  109. data/test/test_condition.rb +52 -0
  110. data/test/test_conditions_disk_usage.rb +50 -0
  111. data/test/test_conditions_http_response_code.rb +109 -0
  112. data/test/test_conditions_process_running.rb +40 -0
  113. data/test/test_conditions_socket_responding.rb +176 -0
  114. data/test/test_conditions_tries.rb +67 -0
  115. data/test/test_contact.rb +109 -0
  116. data/test/test_driver.rb +26 -0
  117. data/test/test_email.rb +34 -0
  118. data/test/test_event_handler.rb +82 -0
  119. data/test/test_god.rb +710 -0
  120. data/test/test_god_system.rb +201 -0
  121. data/test/test_handlers_kqueue_handler.rb +16 -0
  122. data/test/test_hipchat.rb +23 -0
  123. data/test/test_jabber.rb +29 -0
  124. data/test/test_logger.rb +55 -0
  125. data/test/test_metric.rb +74 -0
  126. data/test/test_process.rb +263 -0
  127. data/test/test_prowl.rb +15 -0
  128. data/test/test_registry.rb +15 -0
  129. data/test/test_sensu.rb +11 -0
  130. data/test/test_slack.rb +57 -0
  131. data/test/test_socket.rb +34 -0
  132. data/test/test_statsd.rb +22 -0
  133. data/test/test_sugar.rb +42 -0
  134. data/test/test_system_portable_poller.rb +17 -0
  135. data/test/test_system_process.rb +30 -0
  136. data/test/test_task.rb +246 -0
  137. data/test/test_timeline.rb +37 -0
  138. data/test/test_trigger.rb +63 -0
  139. data/test/test_watch.rb +286 -0
  140. data/test/test_webhook.rb +22 -0
  141. metadata +476 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b4ce1786c5172707e108c78fe2453a8abe133cc9c72e03b680f8e5b4c7ba1724
4
+ data.tar.gz: a16f22c77313029054a253c0b58097c5a72aa9243e20e7657123760aacb1eda5
5
+ SHA512:
6
+ metadata.gz: 210782e580b7588fcd1c5aa229733aff5e6c4e1efe742989b72a3140a8fc271bb35cec71515ca74b15bb1dd23840a9f398e907fc234797a2955134f6f2a2bd0d
7
+ data.tar.gz: 450f3038f899778da0443b753e5719b167fa5ceeb108bd27e707cd32d3311c0e6194972d18b8d30c412a2ca5629e14267ee6c8ba104e2a6d31773196b5df0727
data/Announce.txt ADDED
@@ -0,0 +1,135 @@
1
+ Subject: [ANN] god 0.6.0 released (and mailing list)
2
+
3
+ !!!NEW MAILING LIST!!! We now have a mailing list at http://groups.google.com/group/god-rb
4
+
5
+ This release is primarily focused on increased stability, robustness, and code cleanliness.
6
+
7
+ The last release (0.5.0) switched from TCP sockets to Unix Domain Sockets for the CLI tools. There were some issues regarding file descriptors that would cause god to hang when restarting (the unix socket was being held open by spawned processes). These problems are all fixed in 0.6.0. You may need to kill any processes that were started under god 0.5.0 when you upgrade to 0.6.0 (you will only need to do this once during the upgrade process).
8
+
9
+ More attention is now paid to Syslogging behavior.
10
+
11
+ God will delete its own PID file when terminated via a user request.
12
+
13
+ A new command line option now allows you to check whether your installation properly handles events (sometimes the C extension will compile ok, but still not support events. Gentoo, I'm looking at you). Run `god check` to see an attempt to use the event system. It will tell you if your installation does not support events.
14
+
15
+ A watch can now be removed entirely at runtime using `god remove <watch name>`.
16
+
17
+ A new condition DiskUsage allows you to check the available disk space on a given volume.
18
+
19
+ Updated documentation is now available on the website:
20
+
21
+ http://god.rubyforge.org/
22
+
23
+
24
+ WHAT IS GOD?
25
+
26
+ God is an easy to configure, easy to extend monitoring framework written in Ruby.
27
+
28
+ Keeping your server processes and tasks running should be a simple part of your deployment process. God aims to be the simplest, most powerful monitoring application available.
29
+
30
+
31
+ DISCLAIMER
32
+
33
+ God is still beta so I do not yet recommend you use it for mission critical tasks. We are using it at Powerset, Inc. to monitor our public facing applications, but then, we're daring fellows.
34
+
35
+
36
+ INSTALL
37
+
38
+ sudo gem install god
39
+
40
+
41
+ FEATURES
42
+
43
+ * Config file is written in Ruby
44
+ * Easily write your own custom conditions in Ruby
45
+ * Supports both poll and event based conditions
46
+ * Different poll conditions can have different intervals
47
+ * Easily control non-daemonized processes
48
+
49
+
50
+ EXAMPLE
51
+
52
+ The easiest way to understand how god will make your life better is by looking at a sample config file. The following configuration file is what I use at gravatar.com to keep the mongrels running:
53
+
54
+ # run with: god -c /path/to/gravatar.god
55
+ #
56
+ # This is the actual config file used to keep the mongrels of
57
+ # gravatar.com running.
58
+
59
+ RAILS_ROOT = "/Users/tom/dev/gravatar2"
60
+
61
+ %w{8200 8201 8202}.each do |port|
62
+ God.watch do |w|
63
+ w.name = "gravatar2-mongrel-#{port}"
64
+ w.interval = 30.seconds # default
65
+ w.start = "mongrel_rails start -c #{RAILS_ROOT} -p #{port} \
66
+ -P #{RAILS_ROOT}/log/mongrel.#{port}.pid -d"
67
+ w.stop = "mongrel_rails stop -P #{RAILS_ROOT}/log/mongrel.#{port}.pid"
68
+ w.restart = "mongrel_rails restart -P #{RAILS_ROOT}/log/mongrel.#{port}.pid"
69
+ w.start_grace = 10.seconds
70
+ w.restart_grace = 10.seconds
71
+ w.pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid")
72
+
73
+ w.behavior(:clean_pid_file)
74
+
75
+ w.start_if do |start|
76
+ start.condition(:process_running) do |c|
77
+ c.interval = 5.seconds
78
+ c.running = false
79
+ end
80
+ end
81
+
82
+ w.restart_if do |restart|
83
+ restart.condition(:memory_usage) do |c|
84
+ c.above = 150.megabytes
85
+ c.times = [3, 5] # 3 out of 5 intervals
86
+ end
87
+
88
+ restart.condition(:cpu_usage) do |c|
89
+ c.above = 50.percent
90
+ c.times = 5
91
+ end
92
+ end
93
+
94
+ # lifecycle
95
+ w.lifecycle do |on|
96
+ on.condition(:flapping) do |c|
97
+ c.to_state = [:start, :restart]
98
+ c.times = 5
99
+ c.within = 5.minute
100
+ c.transition = :unmonitored
101
+ c.retry_in = 10.minutes
102
+ c.retry_times = 5
103
+ c.retry_within = 2.hours
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+
110
+ DOCS
111
+
112
+ Detailed documentation is available at http://god.rubyforge.org/
113
+
114
+
115
+ CHANGES
116
+
117
+ == 0.6.0 / 2007-12-4
118
+
119
+ * Minor Enhancement
120
+ * Move Syslog calls into God::Logger and clean up all calling code
121
+ * Remove god's pid file on user requested termination
122
+ * Better handling and cleanup of DRb server's unix domain socket
123
+ * Allow shorthand for requesting a god log
124
+ * Add `god check` to make it easier to diagnose event problems
125
+ * Refactor god binary into class/method structure
126
+ * Implement `god remove` to remove a Task altogether
127
+ * New Conditions
128
+ * DiskUsage < PollCondition - trigger if disk usage is above limit on mount [Rudy Desjardins]
129
+
130
+
131
+
132
+ AUTHORS
133
+
134
+ Tom Preston-Werner
135
+ Kevin Clark
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'redcarpet', '< 3.0.0'
5
+ gem 'sanitize', '2.0.3'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2007 Tom Preston-Werner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ ResurrectedGod: The Ruby Framework for Process Management
2
+ ==============================================
3
+
4
+ This project is forked from original [mojombo/god](https://github.com/mojombo/god).
5
+
6
+ * Authors: Tom Preston-Werner, Kevin Clark, Eric Lindvall
7
+ * Website: http://godrb.com
8
+
9
+ Description
10
+ -----------
11
+
12
+ God is an easy to configure, easy to extend monitoring framework written in
13
+ Ruby.
14
+
15
+ Keeping your server processes and tasks running should be a simple part of
16
+ your deployment process. God aims to be the simplest, most powerful monitoring
17
+ application available.
18
+
19
+ Documentation
20
+ -------------
21
+
22
+ See in-repo documentation at `REPO_ROOT/doc`.
23
+ See online documentation at http://godrb.com.
24
+
25
+ Community
26
+ ---------
27
+
28
+ Sign up for the god mailing list at http://groups.google.com/group/god-rb
29
+
30
+ License
31
+ -------
32
+
33
+ See LICENSE file.
data/Rakefile ADDED
@@ -0,0 +1,129 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'rdoc/task'
5
+ require 'date'
6
+
7
+ require_relative 'lib/god/version'
8
+
9
+ #############################################################################
10
+ #
11
+ # Helper functions
12
+ #
13
+ #############################################################################
14
+
15
+ def name
16
+ @name ||= Dir['*.gemspec'].first.split('.').first
17
+ end
18
+
19
+ def version
20
+ God::VERSION
21
+ end
22
+
23
+ def date
24
+ Date.today.to_s
25
+ end
26
+
27
+ def rubyforge_project
28
+ name
29
+ end
30
+
31
+ def gemspec_file
32
+ "#{name}.gemspec"
33
+ end
34
+
35
+ def gem_file
36
+ "#{name}-#{version}.gem"
37
+ end
38
+
39
+ def replace_header(head, header_name)
40
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
41
+ end
42
+
43
+ #############################################################################
44
+ #
45
+ # Standard tasks
46
+ #
47
+ #############################################################################
48
+
49
+ task :default => :test
50
+
51
+ require 'rake/testtask'
52
+ Rake::TestTask.new(:test) do |test|
53
+ file_list = FileList['test/**/test_*.rb']
54
+ file_list = file_list.exclude("test/test_god_system.rb")
55
+ test.test_files = file_list
56
+ test.libs << 'lib' << 'test'
57
+ test.verbose = true
58
+ end
59
+
60
+ Rake::TestTask.new(:system_test) do |test|
61
+ test.libs << 'lib' << 'test'
62
+ test.pattern = 'test/**/test_god_system.rb'
63
+ test.verbose = true
64
+ end
65
+
66
+ desc "Generate RCov test coverage and open in your browser"
67
+ task :coverage do
68
+ require 'rcov'
69
+ sh "rm -fr coverage"
70
+ sh "rcov test/test_*.rb"
71
+ sh "open coverage/index.html"
72
+ end
73
+
74
+ Rake::RDocTask.new do |rdoc|
75
+ rdoc.rdoc_dir = 'rdoc'
76
+ rdoc.title = "#{name} #{version}"
77
+ rdoc.rdoc_files.include('README*')
78
+ rdoc.rdoc_files.include('lib/**/*.rb')
79
+ end
80
+
81
+ desc "Open an irb session preloaded with this library"
82
+ task :console do
83
+ sh "irb -rubygems -r ./lib/#{name}.rb"
84
+ end
85
+
86
+ #############################################################################
87
+ #
88
+ # Custom tasks (add your own tasks here)
89
+ #
90
+ #############################################################################
91
+
92
+ desc "Generate and view the site locally"
93
+ task :site do
94
+ # Generate the dynamic parts of the site.
95
+ puts "Generating dynamic..."
96
+ require 'gollum'
97
+ wiki = Gollum::Wiki.new('.', :base_path => '/doc')
98
+ html = wiki.page('god', 'HEAD').formatted_data.gsub("\342\200\231", "'")
99
+ template = File.read('./site/index.template.html')
100
+ index = template.sub("{{ content }}", html)
101
+ File.open('./site/index.html', 'w') do |f|
102
+ f.write(index)
103
+ end
104
+
105
+ puts "Done. Opening in browser..."
106
+ sh "open site/index.html"
107
+ end
108
+
109
+ desc "Commit the local site to the gh-pages branch and deploy"
110
+ task :site_release do
111
+ # Ensure the gh-pages dir exists so we can generate into it.
112
+ puts "Checking for gh-pages dir..."
113
+ unless File.exist?("./gh-pages")
114
+ puts "No gh-pages directory found. Run the following commands first:"
115
+ puts " `git clone git@github.com:mojombo/god gh-pages"
116
+ puts " `cd gh-pages"
117
+ puts " `git checkout gh-pages`"
118
+ exit(1)
119
+ end
120
+
121
+ # Copy the rest of the site over.
122
+ puts "Copying static..."
123
+ sh "cp -R site/* gh-pages/"
124
+
125
+ # Commit the changes
126
+ sha = `git log`.match(/[a-z0-9]{40}/)[0]
127
+ sh "cd gh-pages && git add . && git commit -m 'Updating to #{sha}.' && git push"
128
+ puts 'Done.'
129
+ end
data/bin/god ADDED
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ STDOUT.sync = true
4
+
5
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
6
+
7
+ require 'optparse'
8
+ require 'drb'
9
+ require 'yaml'
10
+
11
+ begin
12
+ # Save ARGV in case someone wants to use it later
13
+ ORIGINAL_ARGV = ARGV.dup
14
+
15
+ options = {:daemonize => true, :port => 17165, :syslog => true, :events => true}
16
+
17
+ opts = OptionParser.new do |opts|
18
+ opts.banner = <<-EOF
19
+ Usage:
20
+ Starting:
21
+ god [-c <config file>] [-p <port> | -b] [-P <file>] [-l <file>] [-D]
22
+
23
+ Querying:
24
+ god <command> <argument> [-p <port>]
25
+ god <command> [-p <port>]
26
+ god -v
27
+ god -V (must be run as root to be accurate on Linux)
28
+
29
+ Commands:
30
+ start <task or group name> start task or group
31
+ restart <task or group name> restart task or group
32
+ stop <task or group name> stop task or group
33
+ monitor <task or group name> monitor task or group
34
+ unmonitor <task or group name> unmonitor task or group
35
+ remove <task or group name> remove task or group from god
36
+ load <file> [action] load a config into a running god
37
+ log <task name> show realtime log for given task
38
+ status [task or group name] show status
39
+ signal <task or group name> <sig> signal all matching tasks
40
+ quit stop god
41
+ terminate stop god and all tasks
42
+ check run self diagnostic
43
+
44
+ Options:
45
+ EOF
46
+
47
+ opts.on("-cCONFIG", "--config-file CONFIG", "Configuration file") do |x|
48
+ options[:config] = x
49
+ end
50
+
51
+ opts.on("-pPORT", "--port PORT", "Communications port (default 17165)") do |x|
52
+ options[:port] = x
53
+ end
54
+
55
+ opts.on("-b", "--auto-bind", "Auto-bind to an unused port number") do
56
+ options[:port] = "0"
57
+ end
58
+
59
+ opts.on("-PFILE", "--pid FILE", "Where to write the PID file") do |x|
60
+ options[:pid] = x
61
+ end
62
+
63
+ opts.on("-lFILE", "--log FILE", "Where to write the log file") do |x|
64
+ options[:log] = x
65
+ end
66
+
67
+ opts.on("-D", "--no-daemonize", "Don't daemonize") do
68
+ options[:daemonize] = false
69
+ end
70
+
71
+ opts.on("-v", "--version", "Print the version number and exit") do
72
+ options[:version] = true
73
+ end
74
+
75
+ opts.on("-V", "Print extended version and build information") do
76
+ options[:info] = true
77
+ end
78
+
79
+ opts.on("--log-level LEVEL", "Log level [debug|info|warn|error|fatal]") do |x|
80
+ options[:log_level] = x.to_sym
81
+ end
82
+
83
+ opts.on("--no-syslog", "Disable output to syslog") do
84
+ options[:syslog] = false
85
+ end
86
+
87
+ opts.on("--attach PID", "Quit god when the attached process dies") do |x|
88
+ options[:attach] = x
89
+ end
90
+
91
+ opts.on("--no-events", "Disable the event system") do
92
+ options[:events] = false
93
+ end
94
+
95
+ opts.on("--bleakhouse", "Enable bleakhouse profiling") do
96
+ options[:bleakhouse] = true
97
+ end
98
+ end
99
+
100
+ opts.parse!
101
+
102
+ # validate
103
+ if options[:log_level] && ![:debug, :info, :warn, :error, :fatal].include?(options[:log_level])
104
+ abort("Invalid log level '#{options[:log_level]}'")
105
+ end
106
+
107
+ # Use this flag to actually load all of the god infrastructure
108
+ $load_god = true
109
+
110
+ # dispatch
111
+ if !options[:config] && options[:version]
112
+ require 'god'
113
+ God::CLI::Version.version
114
+ elsif !options[:config] && options[:info]
115
+ require 'god'
116
+ God::EventHandler.load
117
+ God::CLI::Version.version_extended
118
+ elsif !options[:config] && command = ARGV[0]
119
+ require 'god'
120
+ God::EventHandler.load
121
+ God::CLI::Command.new(command, options, ARGV)
122
+ else
123
+ require 'god/cli/run'
124
+ God::CLI::Run.new(options)
125
+ end
126
+ rescue Exception => e
127
+ if e.instance_of?(SystemExit)
128
+ raise
129
+ else
130
+ puts 'Uncaught exception'
131
+ puts e.message
132
+ puts e.backtrace.join("\n")
133
+ end
134
+ end