rubber 1.7.0 → 1.7.1
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/CHANGELOG +9 -0
- data/VERSION +1 -1
- data/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +1 -1
- data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf +4 -4
- data/generators/vulcanize/templates/resque/script/resque_worker_management.rb +58 -26
- data/lib/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +1 -1
- data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf +4 -4
- data/lib/generators/vulcanize/templates/resque/script/resque_worker_management.rb +58 -26
- data/lib/rubber.rb +7 -1
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
1.7.0
|
2
|
+
-----
|
3
|
+
|
4
|
+
Better support for Windows in some cases. <a8f3192> [Kevin Menard]
|
5
|
+
Enhanced describe_bundles. <6f2b1f4> [Kevin Menard]
|
6
|
+
Added support for starting EC2 instances with EBS root devices. <9296921> [Kevin Menard]
|
7
|
+
Added support for stopping EC2 instances with EBS root devices. <a2a70ec> [Kevin Menard]
|
8
|
+
Added reboot command for rebooting stuck EC2 instances. <1d29437> [Kevin Menard]
|
9
|
+
|
1
10
|
1.6.3
|
2
11
|
-----
|
3
12
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.7.
|
1
|
+
1.7.1
|
@@ -12,7 +12,7 @@
|
|
12
12
|
packages: [build-essential, git-core, subversion, curl, autoconf, bison, ruby, zlib1g-dev, libssl-dev, libreadline5-dev, libxml2-dev]
|
13
13
|
|
14
14
|
# REQUIRED: the version of rvm itself
|
15
|
-
rvm_version: 1.0.
|
15
|
+
rvm_version: 1.0.15
|
16
16
|
|
17
17
|
# REQUIRED: Set to the rvm version string for the ruby version you wish to use
|
18
18
|
# Run "rvm list known" to see the list of possible options
|
data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf
CHANGED
@@ -6,14 +6,14 @@
|
|
6
6
|
<%
|
7
7
|
PIDFILE = "#{RUBBER_ROOT}/tmp/pids/resque_worker_#{i}.pid"
|
8
8
|
|
9
|
-
start_program = "cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb start #{i}"
|
10
|
-
stop_program = "cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb stop #{i}"
|
9
|
+
start_program = "/usr/bin/sudo -H -u #{rubber_env.app_user} bash -l -c 'cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb start #{i}'"
|
10
|
+
stop_program = "/usr/bin/sudo -H -u #{rubber_env.app_user} bash -l -c 'cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb stop #{i} TERM'"
|
11
11
|
%>
|
12
12
|
|
13
13
|
check process resque_worker_<%= i %> with pidfile <%= PIDFILE %>
|
14
14
|
group resque_worker
|
15
|
-
start program = "
|
16
|
-
stop program = "
|
15
|
+
start program = "<%= start_program %>"
|
16
|
+
stop program = "<%= stop_program %>"
|
17
17
|
|
18
18
|
if totalmem > 350.0 MB for 15 cycles then restart
|
19
19
|
<% end %>
|
@@ -1,22 +1,34 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
STDOUT.sync = true
|
4
|
+
STDERR.sync = true
|
5
|
+
|
6
|
+
def load_env(rubber_only=true)
|
7
|
+
env = ENV["RUBBER_ENV"] ||= "development"
|
8
|
+
root = File.expand_path('../..', __FILE__)
|
9
|
+
rails_env_file = File.join(root, 'config', 'environment.rb')
|
10
|
+
|
11
|
+
if ! rubber_only && File.exists?(rails_env_file)
|
12
|
+
require(rails_env_file)
|
13
|
+
else
|
14
|
+
require "bundler/setup" if File.exist?(File.join(root, "Gemfile"))
|
15
|
+
require "rubber"
|
16
|
+
Rubber::initialize(root, env)
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
20
|
+
|
16
21
|
def start_all(workers)
|
17
22
|
puts "Starting all workers"
|
18
|
-
|
19
|
-
|
23
|
+
# fork then load rails env so script runs quick, yet we don't overload
|
24
|
+
# machine by loading env for each worker
|
25
|
+
daemonize(log_file('all')) do
|
26
|
+
load_env(false)
|
27
|
+
puts "Preloaded environment for all workers"
|
28
|
+
|
29
|
+
workers.each_with_index do |worker, i|
|
30
|
+
start(worker, i)
|
31
|
+
end
|
20
32
|
end
|
21
33
|
end
|
22
34
|
|
@@ -29,6 +41,9 @@ def start(worker, index)
|
|
29
41
|
queues = worker.queues.to_s.split(',')
|
30
42
|
|
31
43
|
daemonize(log_file, pid_file) do
|
44
|
+
# load env for each worker, if starting multiple, this will be a no-op due
|
45
|
+
# to start_all preloading the env
|
46
|
+
load_env(false)
|
32
47
|
resque_worker = Resque::Worker.new(*queues)
|
33
48
|
resque_worker.verbose = ENV['LOGGING'] || ENV['VERBOSE']
|
34
49
|
resque_worker.very_verbose = ENV['VVERBOSE']
|
@@ -36,24 +51,32 @@ def start(worker, index)
|
|
36
51
|
puts "*** Starting worker #{resque_worker}"
|
37
52
|
resque_worker.work(worker.poll_interval.to_i || 5) # interval, will block
|
38
53
|
end
|
54
|
+
|
39
55
|
end
|
40
56
|
|
41
|
-
def stop_all(workers)
|
57
|
+
def stop_all(workers, signal)
|
42
58
|
puts "Stopping all workers"
|
43
59
|
workers.size.times do |i|
|
44
|
-
stop(i)
|
60
|
+
stop(i, signal)
|
45
61
|
end
|
46
62
|
end
|
47
63
|
|
48
|
-
|
64
|
+
# Resque workers respond to a few different signals:
|
65
|
+
#
|
66
|
+
# QUIT - Wait for child to finish processing then exit
|
67
|
+
# TERM / INT - Immediately kill child then exit
|
68
|
+
# USR1 - Immediately kill child but don't exit
|
69
|
+
# USR2 - Don't start to process any new jobs
|
70
|
+
# CONT - Start to process new jobs again after a USR2
|
71
|
+
def stop(index, signal)
|
49
72
|
puts "Stopping worker #{index}"
|
50
|
-
|
73
|
+
|
51
74
|
pid_file = pid_file(index)
|
52
75
|
pid = File.read(pid_file).to_i rescue nil
|
53
76
|
if pid
|
54
|
-
puts "Killing worker #{index}: pid #{pid}"
|
77
|
+
puts "Killing worker #{index}: pid #{pid} - #{signal}"
|
55
78
|
begin
|
56
|
-
Process.kill(
|
79
|
+
Process.kill(signal, pid)
|
57
80
|
rescue Exception => e
|
58
81
|
puts e
|
59
82
|
end
|
@@ -63,19 +86,21 @@ def stop(index)
|
|
63
86
|
end
|
64
87
|
end
|
65
88
|
|
66
|
-
def daemonize(log_file, pid_file)
|
89
|
+
def daemonize(log_file, pid_file=nil)
|
67
90
|
return if fork
|
68
91
|
Process::setsid
|
69
92
|
exit!(0) if fork
|
70
|
-
Dir::chdir(
|
93
|
+
Dir::chdir(Rubber.root)
|
71
94
|
File.umask 0000
|
72
95
|
FileUtils.touch log_file
|
73
96
|
STDIN.reopen log_file
|
74
97
|
STDOUT.reopen log_file, "a"
|
75
98
|
STDERR.reopen log_file, "a"
|
99
|
+
STDOUT.sync = true
|
100
|
+
STDERR.sync = true
|
101
|
+
|
102
|
+
File.open(pid_file, 'w') {|f| f.write("#{Process.pid}") } if pid_file
|
76
103
|
|
77
|
-
File.open(pid_file, 'w') {|f| f.write("#{Process.pid}") }
|
78
|
-
|
79
104
|
yield if block_given?
|
80
105
|
exit(0)
|
81
106
|
end
|
@@ -90,23 +115,30 @@ end
|
|
90
115
|
|
91
116
|
action = ARGV[0]
|
92
117
|
worker_index = ARGV[1] ? ARGV[1].to_i : nil
|
118
|
+
signal = ARGV[2] || "QUIT"
|
93
119
|
if action.nil? || ! %w[start stop restart].include?(action)
|
94
120
|
puts "Usage: script/resque_worker_management.rb [start|stop|restart]"
|
95
121
|
end
|
96
122
|
|
123
|
+
# load just the rubber env so things run quickly
|
124
|
+
load_env(true)
|
97
125
|
workers = Rubber.config.resque_workers
|
98
126
|
|
99
127
|
case action
|
100
128
|
when 'start'
|
101
129
|
worker_index ? start(workers[worker_index], worker_index) : start_all(workers)
|
130
|
+
# sleep a bit to allow daemonization to complete
|
131
|
+
sleep 0.5
|
102
132
|
when 'stop'
|
103
|
-
worker_index ? stop(worker_index) : stop_all(workers)
|
133
|
+
worker_index ? stop(worker_index, signal) : stop_all(workers, signal)
|
104
134
|
when 'restart'
|
105
135
|
if worker_index
|
106
|
-
stop(worker_index)
|
136
|
+
stop(worker_index, signal)
|
107
137
|
start(workers[worker_index], worker_index)
|
108
138
|
else
|
109
|
-
stop_all(workers)
|
139
|
+
stop_all(workers, signal)
|
110
140
|
start_all(workers)
|
111
141
|
end
|
142
|
+
# sleep a bit to allow daemonization to complete
|
143
|
+
sleep 0.5
|
112
144
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
packages: [build-essential, git-core, subversion, curl, autoconf, bison, ruby, zlib1g-dev, libssl-dev, libreadline5-dev, libxml2-dev]
|
13
13
|
|
14
14
|
# REQUIRED: the version of rvm itself
|
15
|
-
rvm_version: 1.0.
|
15
|
+
rvm_version: 1.0.15
|
16
16
|
|
17
17
|
# REQUIRED: Set to the rvm version string for the ruby version you wish to use
|
18
18
|
# Run "rvm list known" to see the list of possible options
|
@@ -6,14 +6,14 @@
|
|
6
6
|
<%
|
7
7
|
PIDFILE = "#{RUBBER_ROOT}/tmp/pids/resque_worker_#{i}.pid"
|
8
8
|
|
9
|
-
start_program = "cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb start #{i}"
|
10
|
-
stop_program = "cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb stop #{i}"
|
9
|
+
start_program = "/usr/bin/sudo -H -u #{rubber_env.app_user} bash -l -c 'cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb start #{i}'"
|
10
|
+
stop_program = "/usr/bin/sudo -H -u #{rubber_env.app_user} bash -l -c 'cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb stop #{i} TERM'"
|
11
11
|
%>
|
12
12
|
|
13
13
|
check process resque_worker_<%= i %> with pidfile <%= PIDFILE %>
|
14
14
|
group resque_worker
|
15
|
-
start program = "
|
16
|
-
stop program = "
|
15
|
+
start program = "<%= start_program %>"
|
16
|
+
stop program = "<%= stop_program %>"
|
17
17
|
|
18
18
|
if totalmem > 350.0 MB for 15 cycles then restart
|
19
19
|
<% end %>
|
@@ -1,22 +1,34 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
STDOUT.sync = true
|
4
|
+
STDERR.sync = true
|
5
|
+
|
6
|
+
def load_env(rubber_only=true)
|
7
|
+
env = ENV["RUBBER_ENV"] ||= "development"
|
8
|
+
root = File.expand_path('../..', __FILE__)
|
9
|
+
rails_env_file = File.join(root, 'config', 'environment.rb')
|
10
|
+
|
11
|
+
if ! rubber_only && File.exists?(rails_env_file)
|
12
|
+
require(rails_env_file)
|
13
|
+
else
|
14
|
+
require "bundler/setup" if File.exist?(File.join(root, "Gemfile"))
|
15
|
+
require "rubber"
|
16
|
+
Rubber::initialize(root, env)
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
20
|
+
|
16
21
|
def start_all(workers)
|
17
22
|
puts "Starting all workers"
|
18
|
-
|
19
|
-
|
23
|
+
# fork then load rails env so script runs quick, yet we don't overload
|
24
|
+
# machine by loading env for each worker
|
25
|
+
daemonize(log_file('all')) do
|
26
|
+
load_env(false)
|
27
|
+
puts "Preloaded environment for all workers"
|
28
|
+
|
29
|
+
workers.each_with_index do |worker, i|
|
30
|
+
start(worker, i)
|
31
|
+
end
|
20
32
|
end
|
21
33
|
end
|
22
34
|
|
@@ -29,6 +41,9 @@ def start(worker, index)
|
|
29
41
|
queues = worker.queues.to_s.split(',')
|
30
42
|
|
31
43
|
daemonize(log_file, pid_file) do
|
44
|
+
# load env for each worker, if starting multiple, this will be a no-op due
|
45
|
+
# to start_all preloading the env
|
46
|
+
load_env(false)
|
32
47
|
resque_worker = Resque::Worker.new(*queues)
|
33
48
|
resque_worker.verbose = ENV['LOGGING'] || ENV['VERBOSE']
|
34
49
|
resque_worker.very_verbose = ENV['VVERBOSE']
|
@@ -36,24 +51,32 @@ def start(worker, index)
|
|
36
51
|
puts "*** Starting worker #{resque_worker}"
|
37
52
|
resque_worker.work(worker.poll_interval.to_i || 5) # interval, will block
|
38
53
|
end
|
54
|
+
|
39
55
|
end
|
40
56
|
|
41
|
-
def stop_all(workers)
|
57
|
+
def stop_all(workers, signal)
|
42
58
|
puts "Stopping all workers"
|
43
59
|
workers.size.times do |i|
|
44
|
-
stop(i)
|
60
|
+
stop(i, signal)
|
45
61
|
end
|
46
62
|
end
|
47
63
|
|
48
|
-
|
64
|
+
# Resque workers respond to a few different signals:
|
65
|
+
#
|
66
|
+
# QUIT - Wait for child to finish processing then exit
|
67
|
+
# TERM / INT - Immediately kill child then exit
|
68
|
+
# USR1 - Immediately kill child but don't exit
|
69
|
+
# USR2 - Don't start to process any new jobs
|
70
|
+
# CONT - Start to process new jobs again after a USR2
|
71
|
+
def stop(index, signal)
|
49
72
|
puts "Stopping worker #{index}"
|
50
|
-
|
73
|
+
|
51
74
|
pid_file = pid_file(index)
|
52
75
|
pid = File.read(pid_file).to_i rescue nil
|
53
76
|
if pid
|
54
|
-
puts "Killing worker #{index}: pid #{pid}"
|
77
|
+
puts "Killing worker #{index}: pid #{pid} - #{signal}"
|
55
78
|
begin
|
56
|
-
Process.kill(
|
79
|
+
Process.kill(signal, pid)
|
57
80
|
rescue Exception => e
|
58
81
|
puts e
|
59
82
|
end
|
@@ -63,19 +86,21 @@ def stop(index)
|
|
63
86
|
end
|
64
87
|
end
|
65
88
|
|
66
|
-
def daemonize(log_file, pid_file)
|
89
|
+
def daemonize(log_file, pid_file=nil)
|
67
90
|
return if fork
|
68
91
|
Process::setsid
|
69
92
|
exit!(0) if fork
|
70
|
-
Dir::chdir(
|
93
|
+
Dir::chdir(Rubber.root)
|
71
94
|
File.umask 0000
|
72
95
|
FileUtils.touch log_file
|
73
96
|
STDIN.reopen log_file
|
74
97
|
STDOUT.reopen log_file, "a"
|
75
98
|
STDERR.reopen log_file, "a"
|
99
|
+
STDOUT.sync = true
|
100
|
+
STDERR.sync = true
|
101
|
+
|
102
|
+
File.open(pid_file, 'w') {|f| f.write("#{Process.pid}") } if pid_file
|
76
103
|
|
77
|
-
File.open(pid_file, 'w') {|f| f.write("#{Process.pid}") }
|
78
|
-
|
79
104
|
yield if block_given?
|
80
105
|
exit(0)
|
81
106
|
end
|
@@ -90,23 +115,30 @@ end
|
|
90
115
|
|
91
116
|
action = ARGV[0]
|
92
117
|
worker_index = ARGV[1] ? ARGV[1].to_i : nil
|
118
|
+
signal = ARGV[2] || "QUIT"
|
93
119
|
if action.nil? || ! %w[start stop restart].include?(action)
|
94
120
|
puts "Usage: script/resque_worker_management.rb [start|stop|restart]"
|
95
121
|
end
|
96
122
|
|
123
|
+
# load just the rubber env so things run quickly
|
124
|
+
load_env(true)
|
97
125
|
workers = Rubber.config.resque_workers
|
98
126
|
|
99
127
|
case action
|
100
128
|
when 'start'
|
101
129
|
worker_index ? start(workers[worker_index], worker_index) : start_all(workers)
|
130
|
+
# sleep a bit to allow daemonization to complete
|
131
|
+
sleep 0.5
|
102
132
|
when 'stop'
|
103
|
-
worker_index ? stop(worker_index) : stop_all(workers)
|
133
|
+
worker_index ? stop(worker_index, signal) : stop_all(workers, signal)
|
104
134
|
when 'restart'
|
105
135
|
if worker_index
|
106
|
-
stop(worker_index)
|
136
|
+
stop(worker_index, signal)
|
107
137
|
start(workers[worker_index], worker_index)
|
108
138
|
else
|
109
|
-
stop_all(workers)
|
139
|
+
stop_all(workers, signal)
|
110
140
|
start_all(workers)
|
111
141
|
end
|
142
|
+
# sleep a bit to allow daemonization to complete
|
143
|
+
sleep 0.5
|
112
144
|
end
|
data/lib/rubber.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 1.7.
|
9
|
+
- 1
|
10
|
+
version: 1.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Conway
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-22 00:00:00 -04:00
|
19
19
|
default_executable: vulcanize
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|