godhead 0.0.2 → 0.0.3
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.
- data/README.textile +50 -0
- data/Rakefile +2 -12
- data/VERSION +1 -1
- data/examples/etc/god.conf +14 -0
- data/examples/etc/god/god_config.yaml +10 -0
- data/examples/etc/god/sample_project.god +31 -0
- data/examples/etc/init.d/god +48 -0
- data/godhead.gemspec +27 -15
- data/lib/godhead/extensions.rb +1 -0
- data/lib/godhead/extensions/string.rb +9 -0
- data/lib/godhead/god_email.rb +45 -0
- data/lib/godhead/god_recipe.rb +20 -13
- data/lib/godhead/notifications.rb +43 -0
- data/lib/godhead/recipes.rb +6 -2
- data/lib/godhead/recipes/beanstalkd_recipe.rb +13 -6
- data/lib/godhead/recipes/delayed_job_recipe.rb +126 -0
- data/lib/godhead/recipes/generic_worker_recipe.rb +14 -5
- data/lib/godhead/recipes/memcached_recipe.rb +1 -1
- data/lib/godhead/recipes/mongrel_recipe.rb +29 -0
- data/lib/godhead/recipes/mysql_recipe.rb +20 -0
- data/lib/godhead/recipes/nginx_recipe.rb +24 -7
- data/lib/godhead/recipes/resque_recipe.rb +63 -0
- data/lib/godhead/recipes/starling_recipe.rb +3 -2
- data/lib/godhead/recipes/thin_recipe.rb +12 -19
- data/lib/godhead/recipes/thinking_sphinx.rb +98 -0
- data/lib/godhead/recipes/tyrant_recipe.rb +11 -0
- data/lib/godhead/recipes/unicorn_recipe.rb +42 -0
- data/lib/godhead/recipes/workling_recipe.rb +23 -0
- metadata +21 -10
- data/README-god.textile +0 -54
- data/lib/godhead/notification.rb +0 -45
- data/lib/godhead/notification/gmail.rb +0 -0
- data/sample.god +0 -36
@@ -0,0 +1,98 @@
|
|
1
|
+
# From Jesse Newland http://jnewland.com at http://gist.github.com/188053
|
2
|
+
#
|
3
|
+
|
4
|
+
# God.watch do |w|
|
5
|
+
# w.name = "delayed_delta"
|
6
|
+
# w.group = "sphinx"
|
7
|
+
# w.interval = 30.seconds
|
8
|
+
# w.start = "rake -f #{RAILS_ROOT}/Rakefile thinking_sphinx:delayed_delta"
|
9
|
+
# w.env = { "RAILS_ENV" => "production"}
|
10
|
+
# w.uid = 'rails'
|
11
|
+
# w.gid = 'rails'
|
12
|
+
#
|
13
|
+
# # retart if memory gets too high
|
14
|
+
# w.transition(:up, :restart) do |on|
|
15
|
+
# on.condition(:memory_usage) do |c|
|
16
|
+
# c.above = 300.megabytes
|
17
|
+
# c.times = 2
|
18
|
+
# end
|
19
|
+
# end
|
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
|
+
# c.interval = 5.seconds
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# # failsafe
|
36
|
+
# on.condition(:tries) do |c|
|
37
|
+
# c.times = 5
|
38
|
+
# c.transition = :start
|
39
|
+
# c.interval = 5.seconds
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# # start if process is not running
|
44
|
+
# w.transition(:up, :start) do |on|
|
45
|
+
# on.condition(:process_running) do |c|
|
46
|
+
# c.running = false
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
# God.watch do |w|
|
51
|
+
# w.name = "searchd"
|
52
|
+
# w.group = "sphinx"
|
53
|
+
# w.interval = 30.seconds
|
54
|
+
# w.start = "searchd --config #{RAILS_ROOT}/config/#{RAILS_ENV}.sphinx.conf"
|
55
|
+
# w.start_grace = 10.seconds
|
56
|
+
# w.stop = "searchd --config #{RAILS_ROOT}/config/#{RAILS_ENV}.sphinx.conf --stop"
|
57
|
+
# w.stop_grace = 10.seconds
|
58
|
+
# w.pid_file = "#{RAILS_ROOT}/log/searchd.#{RAILS_ENV}.pid"
|
59
|
+
# w.uid = 'rails'
|
60
|
+
# w.gid = 'rails'
|
61
|
+
#
|
62
|
+
# # retart if memory gets too high
|
63
|
+
# w.transition(:up, :restart) do |on|
|
64
|
+
# on.condition(:memory_usage) do |c|
|
65
|
+
# c.above = 300.megabytes
|
66
|
+
# c.times = 2
|
67
|
+
# end
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# # determine the state on startup
|
71
|
+
# w.transition(:init, { true => :up, false => :start }) do |on|
|
72
|
+
# on.condition(:process_running) do |c|
|
73
|
+
# c.running = true
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
#
|
77
|
+
# # determine when process has finished starting
|
78
|
+
# w.transition([:start, :restart], :up) do |on|
|
79
|
+
# on.condition(:process_running) do |c|
|
80
|
+
# c.running = true
|
81
|
+
# c.interval = 5.seconds
|
82
|
+
# end
|
83
|
+
#
|
84
|
+
# # failsafe
|
85
|
+
# on.condition(:tries) do |c|
|
86
|
+
# c.times = 5
|
87
|
+
# c.transition = :start
|
88
|
+
# c.interval = 5.seconds
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# # start if process is not running
|
93
|
+
# w.transition(:up, :start) do |on|
|
94
|
+
# on.condition(:process_running) do |c|
|
95
|
+
# c.running = false
|
96
|
+
# end
|
97
|
+
# end
|
98
|
+
# end
|
@@ -1,4 +1,9 @@
|
|
1
1
|
module Godhead
|
2
|
+
#
|
3
|
+
# Tokyo Tyrant
|
4
|
+
#
|
5
|
+
# Lets god do the process management by killing/restarting according to the
|
6
|
+
# pid file
|
2
7
|
class TyrantRecipe < GodRecipe
|
3
8
|
DEFAULT_OPTIONS = {
|
4
9
|
:max_cpu_usage => 50.percent,
|
@@ -33,6 +38,12 @@ module Godhead
|
|
33
38
|
dbname
|
34
39
|
].flatten.compact.join(" ")
|
35
40
|
end
|
41
|
+
|
42
|
+
# don't try to invent a pid_file -- by default god will find and make one
|
43
|
+
# and will handle task killing/restarting/etc.
|
44
|
+
def pid_file()
|
45
|
+
nil
|
46
|
+
end
|
36
47
|
end
|
37
48
|
end
|
38
49
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Godhead
|
2
|
+
#
|
3
|
+
# Unicorn monitoring recipe
|
4
|
+
#
|
5
|
+
# inspired by http://railscasts.com/episodes/130-monitoring-with-god
|
6
|
+
class UnicornRecipe < GodRecipe
|
7
|
+
DEFAULT_OPTIONS = {
|
8
|
+
:max_cpu_usage => 10.percent,
|
9
|
+
:max_mem_usage => 50.megabytes,
|
10
|
+
:uid => nil, # probably want to set this
|
11
|
+
#
|
12
|
+
:root_dir => nil, # required to set this
|
13
|
+
:runner_path => 'unicorn',
|
14
|
+
:runner_conf => 'unicorn-conf.rb',
|
15
|
+
:runner_env => 'production',
|
16
|
+
}
|
17
|
+
def self.default_options() super.deep_merge(DEFAULT_OPTIONS) ; end
|
18
|
+
|
19
|
+
def start_command
|
20
|
+
[
|
21
|
+
"cd #{options[:root_dir]} && #{options[:runner_path]}",
|
22
|
+
"-c #{options[:runner_conf]}", # config file
|
23
|
+
"-E #{options[:runner_env]}", # environment
|
24
|
+
"-D", # daemonize
|
25
|
+
].flatten.compact.join(" ")
|
26
|
+
end
|
27
|
+
|
28
|
+
def pid_file
|
29
|
+
options[:pid_file] || options[:root_dir]+'/tmp/unicorn.pid'
|
30
|
+
end
|
31
|
+
|
32
|
+
# send QUIT signal: gracefully shuts down workers
|
33
|
+
def stop_command
|
34
|
+
"kill -QUIT `cat #{pid_file}`"
|
35
|
+
end
|
36
|
+
|
37
|
+
# # USR2 causes the master to re-create itself and spawn a new worker pool
|
38
|
+
def restart_command
|
39
|
+
"kill -USR2 `cat #{pid_file}`"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Godhead
|
2
|
+
#
|
3
|
+
# Workling monitoring recipe
|
4
|
+
#
|
5
|
+
# inspired by http://railscasts.com/episodes/130-monitoring-with-god
|
6
|
+
class WorklingRecipe < GenericWorkerRecipe
|
7
|
+
DEFAULT_OPTIONS = {
|
8
|
+
:max_cpu_usage => 80.percent,
|
9
|
+
:max_mem_usage => 100.megabytes,
|
10
|
+
:start_grace_time => 20.seconds,
|
11
|
+
#
|
12
|
+
:runner_path => nil,
|
13
|
+
}
|
14
|
+
def self.default_options() super.deep_merge(DEFAULT_OPTIONS) ; end
|
15
|
+
|
16
|
+
def tell_runner action
|
17
|
+
"#{options[:runner_path]} #{action}"
|
18
|
+
end
|
19
|
+
def start_command() tell_runner 'start' end
|
20
|
+
def stop_command() tell_runner 'stop' end
|
21
|
+
def restart_command() tell_runner 'restart' end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: godhead
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip (flip) Kromer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-11 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -23,8 +23,8 @@ dependencies:
|
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
type: :
|
26
|
+
name: god
|
27
|
+
type: :runtime
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: activesupport
|
37
37
|
type: :runtime
|
38
38
|
version_requirement:
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,33 +50,44 @@ extensions: []
|
|
50
50
|
|
51
51
|
extra_rdoc_files:
|
52
52
|
- LICENSE
|
53
|
-
- README
|
53
|
+
- README.textile
|
54
54
|
files:
|
55
55
|
- .document
|
56
56
|
- .gitignore
|
57
57
|
- LICENSE
|
58
|
-
- README
|
58
|
+
- README.textile
|
59
59
|
- Rakefile
|
60
60
|
- VERSION
|
61
|
+
- examples/etc/god.conf
|
62
|
+
- examples/etc/god/god_config.yaml
|
63
|
+
- examples/etc/god/sample_project.god
|
64
|
+
- examples/etc/init.d/god
|
61
65
|
- godhead.gemspec
|
62
66
|
- lib/godhead.rb
|
63
67
|
- lib/godhead/extensions.rb
|
64
68
|
- lib/godhead/extensions/hash.rb
|
69
|
+
- lib/godhead/extensions/string.rb
|
70
|
+
- lib/godhead/god_email.rb
|
65
71
|
- lib/godhead/god_recipe.rb
|
66
72
|
- lib/godhead/mixins.rb
|
67
73
|
- lib/godhead/mixins/runs_as_service.rb
|
68
|
-
- lib/godhead/
|
69
|
-
- lib/godhead/notification/gmail.rb
|
74
|
+
- lib/godhead/notifications.rb
|
70
75
|
- lib/godhead/process_groups.rb
|
71
76
|
- lib/godhead/recipes.rb
|
72
77
|
- lib/godhead/recipes/beanstalkd_recipe.rb
|
78
|
+
- lib/godhead/recipes/delayed_job_recipe.rb
|
73
79
|
- lib/godhead/recipes/generic_worker_recipe.rb
|
74
80
|
- lib/godhead/recipes/memcached_recipe.rb
|
81
|
+
- lib/godhead/recipes/mongrel_recipe.rb
|
82
|
+
- lib/godhead/recipes/mysql_recipe.rb
|
75
83
|
- lib/godhead/recipes/nginx_recipe.rb
|
84
|
+
- lib/godhead/recipes/resque_recipe.rb
|
76
85
|
- lib/godhead/recipes/starling_recipe.rb
|
77
86
|
- lib/godhead/recipes/thin_recipe.rb
|
87
|
+
- lib/godhead/recipes/thinking_sphinx.rb
|
78
88
|
- lib/godhead/recipes/tyrant_recipe.rb
|
79
|
-
-
|
89
|
+
- lib/godhead/recipes/unicorn_recipe.rb
|
90
|
+
- lib/godhead/recipes/workling_recipe.rb
|
80
91
|
- spec/godhead_spec.rb
|
81
92
|
- spec/spec_helper.rb
|
82
93
|
has_rdoc: true
|
data/README-god.textile
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
Keep running:
|
2
|
-
|
3
|
-
* Worker queue (beanstalkd)
|
4
|
-
* Backing store (ttserver)
|
5
|
-
* Request queue-fed Scrapers (list of scripts)
|
6
|
-
* Feed/Periodic scrapers
|
7
|
-
* Constant scrapers
|
8
|
-
|
9
|
-
* http://god.rubyforge.org/
|
10
|
-
* http://railscasts.com/episodes/130-monitoring-with-god
|
11
|
-
|
12
|
-
sudo gem install god
|
13
|
-
god -c config/mailit.god
|
14
|
-
god status
|
15
|
-
god terminate
|
16
|
-
god log mailit-workling
|
17
|
-
kill `cat log/workling.pid`
|
18
|
-
|
19
|
-
* http://nubyonrails.com/articles/about-this-blog-beanstalk-messaging-queue
|
20
|
-
** The "god.conf":http://pastie.textmate.org/private/ovgxu2ihoicli2ktrwtbew is
|
21
|
-
taken from there.
|
22
|
-
|
23
|
-
h2. Beanstalkd
|
24
|
-
|
25
|
-
*Usage*:
|
26
|
-
|
27
|
-
beanstalkd --help
|
28
|
-
Use: beanstalkd [OPTIONS]
|
29
|
-
|
30
|
-
Options:
|
31
|
-
-d detach
|
32
|
-
-l ADDR listen on address (default is 0.0.0.0)
|
33
|
-
-p PORT listen on port (default is 11300)
|
34
|
-
-u USER become user and group
|
35
|
-
-z SIZE set the maximum job size in bytes (default is 65535)
|
36
|
-
-v show version information
|
37
|
-
-h show this help
|
38
|
-
|
39
|
-
|
40
|
-
h2. Tokyo Tyrant
|
41
|
-
|
42
|
-
*Usage*:
|
43
|
-
|
44
|
-
ttserver --help
|
45
|
-
ttserver: the server of Tokyo Tyrant
|
46
|
-
|
47
|
-
usage:
|
48
|
-
ttserver [-host name] [-port num] [-thnum num] [-tout num] [-dmn]
|
49
|
-
[-pid path] [-kl] [-log path] [-ld|-le] [-ulog path]
|
50
|
-
[-ulim num] [-uas] [-sid num]
|
51
|
-
[-mhost name] [-mport num] [-rts path] [-rcc] [-skel name]
|
52
|
-
[-ext path] [-extpc name period] [-mask expr] [-unmask expr] [dbname]
|
53
|
-
|
54
|
-
|
data/lib/godhead/notification.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
module God
|
2
|
-
def self.setup_email options
|
3
|
-
God::Contacts::Email.message_settings = {
|
4
|
-
:from => options[:username], }
|
5
|
-
God.contact(:email) do |c|
|
6
|
-
c.name = options[:to_name]
|
7
|
-
c.email = options[:to]
|
8
|
-
c.group = options[:group] || 'default'
|
9
|
-
end
|
10
|
-
if options[:address] then delivery_by_smtp(options)
|
11
|
-
else delivery_by_gmail(options) end
|
12
|
-
end
|
13
|
-
|
14
|
-
#
|
15
|
-
# GMail
|
16
|
-
#
|
17
|
-
# http://millarian.com/programming/ruby-on-rails/monitoring-thin-using-god-with-google-apps-notifications/
|
18
|
-
def self.delivery_by_gmail options
|
19
|
-
require 'tlsmail'
|
20
|
-
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
|
21
|
-
God::Contacts::Email.server_settings = {
|
22
|
-
:address => 'smtp.gmail.com',
|
23
|
-
:tls => 'true',
|
24
|
-
:port => 587,
|
25
|
-
:domain => options[:email_domain],
|
26
|
-
:user_name => options[:username],
|
27
|
-
:password => options[:password],
|
28
|
-
:authentication => :plain
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# SMTP email
|
34
|
-
#
|
35
|
-
def self.delivery_by_smtp options
|
36
|
-
God::Contacts::Email.server_settings = {
|
37
|
-
:address => options[:address],
|
38
|
-
:port => 25,
|
39
|
-
:domain => options[:email_domain],
|
40
|
-
:user_name => options[:username],
|
41
|
-
:password => options[:password],
|
42
|
-
:authentication => :plain,
|
43
|
-
}
|
44
|
-
end
|
45
|
-
end
|
File without changes
|
data/sample.god
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
require 'god'
|
4
|
-
require 'active_support'
|
5
|
-
$: << File.dirname(__FILE__)+'/lib'
|
6
|
-
require 'godhead'
|
7
|
-
|
8
|
-
YUPFRONT_ROOT = "/slice/www/apps/yuploader_static/yupfront"
|
9
|
-
|
10
|
-
# ===========================================================================
|
11
|
-
#
|
12
|
-
# Yupshot god monitoring: the backend processing chain for yuploader
|
13
|
-
#
|
14
|
-
group_options = { :monitor_group => :yupshot, }
|
15
|
-
|
16
|
-
Godhead::MemcachedRecipe.create group_options.merge({ :user => 'www-data', :pid_file => '/tmp/mc.pid'})
|
17
|
-
Godhead::StarlingRecipe.create group_options
|
18
|
-
Godhead::GenericWorkerRecipe.create group_options.merge({
|
19
|
-
:runner_path => "/slice/www/apps/yuploader_static/yupshot/bin/yupshot_worker_daemon" })
|
20
|
-
|
21
|
-
# ===========================================================================
|
22
|
-
#
|
23
|
-
# Yupfront god monitoring: the frontend processes for yuploader
|
24
|
-
#
|
25
|
-
group_options = { :monitor_group => :yupfront}
|
26
|
-
|
27
|
-
Godhead::NginxRecipe.create group_options.merge({ })
|
28
|
-
# replace with this one on OSX
|
29
|
-
# Godhead::NginxRunnerRecipe.create group_options.merge({ })
|
30
|
-
|
31
|
-
(5000..5003).each do |port|
|
32
|
-
Godhead::ThinRecipe.create(group_options.merge({
|
33
|
-
:port => port,
|
34
|
-
:rackup_file => File.join(YUPFRONT_ROOT, 'config.ru'),
|
35
|
-
:runner_conf => File.join(YUPFRONT_ROOT, 'production.yml') }))
|
36
|
-
end
|