eye 0.8.celluloid15 → 0.8.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -5
- data/CHANGES.md +3 -7
- data/README.md +2 -5
- data/Rakefile +6 -6
- data/bin/leye +4 -9
- data/bin/loader_eye +15 -14
- data/examples/delayed_job.eye +3 -3
- data/examples/dependency.eye +11 -10
- data/examples/notify.eye +4 -3
- data/examples/plugin/main.eye +5 -5
- data/examples/plugin/plugin.rb +2 -10
- data/examples/process_thin.rb +8 -8
- data/examples/processes/em.rb +12 -18
- data/examples/processes/forking.rb +5 -5
- data/examples/processes/sample.rb +44 -46
- data/examples/puma.eye +8 -9
- data/examples/rbenv.eye +5 -5
- data/examples/sidekiq.eye +3 -3
- data/examples/stress_test.eye +4 -4
- data/examples/syslog.eye +1 -1
- data/examples/test.eye +2 -1
- data/examples/thin-farm.eye +8 -7
- data/examples/triggers.eye +15 -13
- data/examples/unicorn.eye +13 -12
- data/eye.gemspec +14 -16
- data/lib/eye.rb +3 -2
- data/lib/eye/application.rb +6 -5
- data/lib/eye/checker.rb +25 -44
- data/lib/eye/checker/children_count.rb +1 -1
- data/lib/eye/checker/file_ctime.rb +1 -1
- data/lib/eye/checker/http.rb +15 -13
- data/lib/eye/checker/nop.rb +0 -1
- data/lib/eye/checker/socket.rb +63 -60
- data/lib/eye/checker/ssl_socket.rb +5 -5
- data/lib/eye/child_process.rb +4 -6
- data/lib/eye/cli.rb +46 -74
- data/lib/eye/cli/commands.rb +5 -4
- data/lib/eye/cli/render.rb +41 -61
- data/lib/eye/cli/server.rb +16 -19
- data/lib/eye/client.rb +0 -1
- data/lib/eye/config.rb +33 -36
- data/lib/eye/controller.rb +3 -2
- data/lib/eye/controller/commands.rb +1 -1
- data/lib/eye/controller/helpers.rb +2 -2
- data/lib/eye/controller/load.rb +17 -19
- data/lib/eye/controller/options.rb +5 -1
- data/lib/eye/controller/send_command.rb +23 -21
- data/lib/eye/controller/status.rb +15 -17
- data/lib/eye/dsl.rb +1 -6
- data/lib/eye/dsl/application_opts.rb +3 -4
- data/lib/eye/dsl/chain.rb +2 -2
- data/lib/eye/dsl/child_process_opts.rb +3 -3
- data/lib/eye/dsl/config_opts.rb +7 -7
- data/lib/eye/dsl/group_opts.rb +3 -3
- data/lib/eye/dsl/helpers.rb +1 -1
- data/lib/eye/dsl/main.rb +3 -4
- data/lib/eye/dsl/opts.rb +28 -31
- data/lib/eye/dsl/process_opts.rb +7 -13
- data/lib/eye/dsl/pure_opts.rb +9 -13
- data/lib/eye/dsl/validation.rb +35 -48
- data/lib/eye/group.rb +8 -23
- data/lib/eye/group/chain.rb +6 -6
- data/lib/eye/loader.rb +3 -3
- data/lib/eye/local.rb +4 -9
- data/lib/eye/logger.rb +4 -11
- data/lib/eye/notify.rb +6 -10
- data/lib/eye/notify/jabber.rb +1 -1
- data/lib/eye/notify/mail.rb +2 -2
- data/lib/eye/notify/slack.rb +3 -4
- data/lib/eye/process.rb +0 -2
- data/lib/eye/process/children.rb +4 -4
- data/lib/eye/process/commands.rb +39 -38
- data/lib/eye/process/config.rb +16 -22
- data/lib/eye/process/controller.rb +19 -5
- data/lib/eye/process/data.rb +9 -11
- data/lib/eye/process/monitor.rb +76 -86
- data/lib/eye/process/notify.rb +10 -10
- data/lib/eye/process/scheduler.rb +31 -36
- data/lib/eye/process/states.rb +5 -7
- data/lib/eye/process/states_history.rb +3 -9
- data/lib/eye/process/system.rb +20 -35
- data/lib/eye/process/trigger.rb +5 -1
- data/lib/eye/process/watchers.rb +9 -12
- data/lib/eye/reason.rb +1 -4
- data/lib/eye/server.rb +1 -2
- data/lib/eye/system.rb +15 -22
- data/lib/eye/system_resources.rb +9 -18
- data/lib/eye/trigger.rb +16 -18
- data/lib/eye/trigger/check_dependency.rb +4 -7
- data/lib/eye/trigger/flapping.rb +7 -24
- data/lib/eye/trigger/starting_guard.rb +6 -7
- data/lib/eye/trigger/stop_children.rb +2 -2
- data/lib/eye/trigger/transition.rb +1 -1
- data/lib/eye/trigger/wait_dependency.rb +2 -3
- data/lib/eye/utils.rb +3 -4
- data/lib/eye/utils/alive_array.rb +4 -9
- data/lib/eye/utils/celluloid_chain.rb +10 -12
- data/lib/eye/utils/leak_19.rb +10 -0
- data/lib/eye/utils/mini_active_support.rb +16 -16
- data/lib/eye/utils/pmap.rb +0 -2
- data/lib/eye/utils/tail.rb +2 -2
- metadata +8 -39
- data/.rubocop.yml +0 -141
- data/examples/custom_check.eye +0 -24
- data/examples/custom_trigger.eye +0 -30
- data/examples/leye_example/Eyefile +0 -10
@@ -4,13 +4,13 @@ require 'forking'
|
|
4
4
|
root = File.expand_path(File.dirname(__FILE__))
|
5
5
|
cnt = (ENV['FORKING_COUNT'] || 3).to_i
|
6
6
|
|
7
|
-
f = Forking.new(name
|
8
|
-
|
9
|
-
|
7
|
+
f = Forking.new(:name => 'forking', :working_dir => root,
|
8
|
+
:log_file => "#{root}/forking.log",
|
9
|
+
:pid_file => "#{root}/forking.pid", :sync_log => true)
|
10
10
|
|
11
11
|
cnt.times do |i|
|
12
|
-
f.spawn(log_file
|
13
|
-
$0 =
|
12
|
+
f.spawn(:log_file => "#{root}/child#{i}.log", :sync_log => true) do
|
13
|
+
$0 = "forking child"
|
14
14
|
t = 0
|
15
15
|
loop do
|
16
16
|
p "#{Time.now} - #{Time.now.to_f} - #{i} - tick"
|
@@ -9,49 +9,49 @@ options = {}
|
|
9
9
|
optparse = OptionParser.new do|opts|
|
10
10
|
# This displays the help screen, all programs are
|
11
11
|
# assumed to have this option.
|
12
|
-
opts.on('-h', '--help', 'Display this screen') do
|
12
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
13
13
|
puts opts
|
14
14
|
exit
|
15
15
|
end
|
16
16
|
|
17
|
-
opts.on('-p', '--pid FILE', 'pid_file') do |a|
|
17
|
+
opts.on( '-p', '--pid FILE', 'pid_file' ) do |a|
|
18
18
|
options[:pid_file] = a
|
19
19
|
end
|
20
20
|
|
21
|
-
opts.on('-l', '--log FILE', 'log_file') do |a|
|
21
|
+
opts.on( '-l', '--log FILE', 'log_file' ) do |a|
|
22
22
|
options[:log_file] = a
|
23
23
|
end
|
24
24
|
|
25
|
-
opts.on('-L', '--lock FILE', 'lock_file') do |a|
|
25
|
+
opts.on( '-L', '--lock FILE', 'lock_file' ) do |a|
|
26
26
|
options[:lock_file] = a
|
27
27
|
end
|
28
28
|
|
29
|
-
opts.on('-d', '--daemonize', 'Daemonize') do
|
29
|
+
opts.on( '-d', '--daemonize', 'Daemonize' ) do
|
30
30
|
options[:daemonize] = true
|
31
31
|
end
|
32
32
|
|
33
|
-
opts.on('-s', '--daemonize_delay DELAY', 'Daemonized time') do |d|
|
33
|
+
opts.on( '-s', '--daemonize_delay DELAY', 'Daemonized time' ) do |d|
|
34
34
|
options[:daemonize_delay] = d
|
35
35
|
end
|
36
36
|
|
37
|
-
opts.on('-r', '--raise', 'Raised execution') do
|
37
|
+
opts.on( '-r', '--raise', 'Raised execution' ) do
|
38
38
|
options[:raise] = true
|
39
39
|
end
|
40
40
|
|
41
|
-
opts.on('-w', '--watch_file FILE', 'Exit on touched file') do |w|
|
41
|
+
opts.on( '-w', '--watch_file FILE', 'Exit on touched file' ) do |w|
|
42
42
|
options[:watch_file] = w
|
43
43
|
end
|
44
44
|
|
45
|
-
opts.on('-W', '--watch_file_delay DELAY', 'Exit on touched file, after delay') do |w|
|
45
|
+
opts.on( '-W', '--watch_file_delay DELAY', 'Exit on touched file, after delay' ) do |w|
|
46
46
|
options[:watch_file_delay] = w
|
47
47
|
end
|
48
|
+
|
48
49
|
end
|
49
50
|
|
50
51
|
optparse.parse!
|
51
52
|
|
52
53
|
module Sample
|
53
|
-
|
54
|
-
def puts(mes = '')
|
54
|
+
def puts(mes = "")
|
55
55
|
tm = Time.now
|
56
56
|
STDOUT.puts "#{tm} (#{tm.to_f}) - #{mes}"
|
57
57
|
STDOUT.flush
|
@@ -63,15 +63,15 @@ module Sample
|
|
63
63
|
if daemonize_delay && daemonize_delay.to_f > 0
|
64
64
|
puts "daemonize delay start #{daemonize_delay}"
|
65
65
|
sleep daemonize_delay.to_f
|
66
|
-
puts
|
66
|
+
puts "daemonize delay end"
|
67
67
|
end
|
68
68
|
|
69
69
|
daemon
|
70
|
-
STDOUT.reopen(log_file,
|
71
|
-
STDERR.reopen(log_file,
|
72
|
-
File.open(pid_file, 'w')
|
70
|
+
STDOUT.reopen(log_file, "a")
|
71
|
+
STDERR.reopen(log_file, "a")
|
72
|
+
File.open(pid_file, 'w'){|f| f.write $$.to_s}
|
73
73
|
|
74
|
-
puts
|
74
|
+
puts "daemonized"
|
75
75
|
end
|
76
76
|
|
77
77
|
def daemon
|
@@ -79,12 +79,11 @@ module Sample
|
|
79
79
|
Process.setsid # Become session leader.
|
80
80
|
exit if fork # Zap session leader. See [1].
|
81
81
|
|
82
|
-
STDIN.reopen
|
83
|
-
STDOUT.reopen
|
82
|
+
STDIN.reopen "/dev/null" # Free file descriptors and
|
83
|
+
STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
|
84
84
|
STDERR.reopen '/dev/null', 'a'
|
85
|
-
0
|
85
|
+
return 0
|
86
86
|
end
|
87
|
-
|
88
87
|
end
|
89
88
|
|
90
89
|
extend Sample
|
@@ -97,50 +96,49 @@ puts "Started #{ARGV.inspect}, #{options.inspect}, #{ENV['ENV1']}"
|
|
97
96
|
|
98
97
|
if options[:lock_file]
|
99
98
|
if File.exist?(options[:lock_file])
|
100
|
-
puts
|
99
|
+
puts "Lock file exists, exiting"
|
101
100
|
exit 1
|
102
101
|
else
|
103
|
-
File.open(options[:lock_file], 'w')
|
102
|
+
File.open(options[:lock_file], 'w'){|f| f.write $$ }
|
104
103
|
end
|
105
104
|
end
|
106
105
|
|
107
106
|
if options[:raise]
|
108
|
-
puts
|
107
|
+
puts "Raised"
|
109
108
|
File.unlink(options[:lock_file]) if options[:lock_file]
|
110
109
|
exit 1
|
111
110
|
end
|
112
111
|
|
113
|
-
trap(
|
114
|
-
puts
|
112
|
+
trap("USR1") do
|
113
|
+
puts "USR1 signal!"
|
115
114
|
end
|
116
115
|
|
117
|
-
trap(
|
118
|
-
puts
|
119
|
-
ar = []
|
120
|
-
300_000.times
|
116
|
+
trap("USR2") do
|
117
|
+
puts "USR2 start memory leak"
|
118
|
+
$ar = []
|
119
|
+
300_000.times{|i| $ar << "memory leak #{i}" * 10}
|
121
120
|
end
|
122
121
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
puts 'watch file finded'
|
127
|
-
File.unlink(options[:watch_file])
|
122
|
+
loop do
|
123
|
+
sleep 0.1
|
124
|
+
puts "tick"
|
128
125
|
|
129
|
-
if options[:
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
126
|
+
if options[:watch_file]
|
127
|
+
if File.exist?(options[:watch_file])
|
128
|
+
puts "watch file finded"
|
129
|
+
File.unlink(options[:watch_file])
|
134
130
|
|
135
|
-
|
136
|
-
|
131
|
+
if options[:watch_file_delay]
|
132
|
+
puts "watch_file delay start"
|
133
|
+
sleep options[:watch_file_delay].to_f
|
134
|
+
puts "watch_file delay end"
|
135
|
+
end
|
137
136
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
break if check_watch_file(options)
|
137
|
+
break
|
138
|
+
end
|
139
|
+
end
|
142
140
|
end
|
143
141
|
|
144
|
-
puts
|
142
|
+
puts "exit"
|
145
143
|
File.unlink(options[:lock_file]) if options[:lock_file]
|
146
144
|
exit 0
|
data/examples/puma.eye
CHANGED
@@ -9,22 +9,21 @@ end
|
|
9
9
|
Eye.application :puma do
|
10
10
|
env 'RAILS_ENV' => RAILS_ENV
|
11
11
|
working_dir ROOT
|
12
|
-
trigger :flapping, times
|
12
|
+
trigger :flapping, :times => 10, :within => 1.minute
|
13
13
|
|
14
14
|
process :puma do
|
15
15
|
daemonize true
|
16
|
-
pid_file
|
17
|
-
stdall
|
16
|
+
pid_file "puma.pid"
|
17
|
+
stdall "puma.log"
|
18
18
|
|
19
19
|
start_command "#{BUNDLE} exec puma --port 33280 --environment #{RAILS_ENV} thin.ru"
|
20
20
|
stop_signals [:TERM, 5.seconds, :KILL]
|
21
|
-
restart_command
|
21
|
+
restart_command "kill -USR2 {PID}"
|
22
22
|
|
23
|
-
# just sleep this until process get up status
|
24
|
-
|
25
|
-
restart_grace 10.seconds
|
23
|
+
restart_grace 10.seconds # just sleep this until process get up status
|
24
|
+
# (maybe enought to puma soft restart)
|
26
25
|
|
27
|
-
check :cpu, every
|
28
|
-
check :memory, every
|
26
|
+
check :cpu, :every => 30, :below => 80, :times => 3
|
27
|
+
check :memory, :every => 30, :below => 70.megabytes, :times => [3,5]
|
29
28
|
end
|
30
29
|
end
|
data/examples/rbenv.eye
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
Eye.application
|
1
|
+
Eye.application "rbenv_example" do
|
2
2
|
env 'RBENV_ROOT' => '/usr/local/rbenv', 'PATH' => "/usr/local/rbenv/shims:/usr/local/rbenv/bin:#{ENV['PATH']}"
|
3
3
|
working_dir File.expand_path(File.join(File.dirname(__FILE__), %w[ processes ]))
|
4
4
|
|
5
|
-
process
|
6
|
-
pid_file
|
7
|
-
start_command
|
5
|
+
process "some_process" do
|
6
|
+
pid_file "some.pid"
|
7
|
+
start_command "ruby some.rb"
|
8
8
|
daemonize true
|
9
|
-
stdall
|
9
|
+
stdall "some.log"
|
10
10
|
end
|
11
11
|
end
|
data/examples/sidekiq.eye
CHANGED
@@ -10,14 +10,14 @@ def sidekiq_process(proxy, name)
|
|
10
10
|
daemonize true
|
11
11
|
stop_signals [:USR1, 0, :TERM, 10.seconds, :KILL]
|
12
12
|
|
13
|
-
check :cpu, every
|
14
|
-
check :memory, every
|
13
|
+
check :cpu, :every => 30, :below => 100, :times => 5
|
14
|
+
check :memory, :every => 30, :below => 300.megabytes, :times => 5
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
Eye.application :sidekiq_test do
|
19
19
|
working_dir File.expand_path(File.join(File.dirname(__FILE__), %w[ processes ]))
|
20
|
-
env
|
20
|
+
env "RAILS_ENV" => 'production'
|
21
21
|
|
22
22
|
sidekiq_process self, :sidekiq
|
23
23
|
end
|
data/examples/stress_test.eye
CHANGED
@@ -3,16 +3,16 @@
|
|
3
3
|
PREFIX = ENV['PRE'] || ENV['EYE_V'] || 1
|
4
4
|
|
5
5
|
Eye.app :stress_test do
|
6
|
-
working_dir
|
6
|
+
working_dir "/tmp"
|
7
7
|
|
8
8
|
100.times do |i|
|
9
9
|
process "sleep-#{i}" do
|
10
10
|
pid_file "sleep-#{PREFIX}-#{i}.pid"
|
11
|
-
start_command
|
11
|
+
start_command "sleep 120"
|
12
12
|
daemonize true
|
13
13
|
|
14
|
-
checks :cpu, every
|
15
|
-
checks :memory, every
|
14
|
+
checks :cpu, :every => 5.seconds, :below => 10, :times => 5
|
15
|
+
checks :memory, :every => 6.seconds, :below => 50.megabytes, :times => 5
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/examples/syslog.eye
CHANGED
data/examples/test.eye
CHANGED
@@ -66,7 +66,7 @@ Eye.application 'test' do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
# eventmachine process, daemonized with eye
|
69
|
-
process :event_machine do
|
69
|
+
process :event_machine do |p|
|
70
70
|
pid_file 'em.pid'
|
71
71
|
start_command 'ruby em.rb'
|
72
72
|
stdout 'em.log'
|
@@ -86,4 +86,5 @@ Eye.application 'test' do
|
|
86
86
|
check :http, url: 'http://127.0.0.1:33233/hello', pattern: /World/,
|
87
87
|
every: 5.seconds, times: [2, 3], timeout: 1.second
|
88
88
|
end
|
89
|
+
|
89
90
|
end
|
data/examples/thin-farm.eye
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
RUBY = 'ruby'
|
2
2
|
BUNDLE = 'bundle'
|
3
3
|
|
4
|
-
Eye.load(
|
4
|
+
Eye.load("process_thin.rb")
|
5
5
|
|
6
6
|
Eye.config do
|
7
|
-
logger
|
7
|
+
logger "/tmp/eye.log"
|
8
8
|
end
|
9
9
|
|
10
10
|
Eye.app 'thin-farm' do
|
11
11
|
working_dir File.expand_path(File.join(File.dirname(__FILE__), %w[ processes ]))
|
12
|
-
env
|
12
|
+
env "RAILS_ENV" => "production"
|
13
13
|
|
14
14
|
# more about stop_on_delete: https://github.com/kostya/eye/wiki/About-stop_on_delete-=-true
|
15
15
|
stop_on_delete true
|
16
16
|
|
17
|
-
trigger :flapping, times
|
18
|
-
check :memory, below
|
17
|
+
trigger :flapping, :times => 10, :within => 1.minute
|
18
|
+
check :memory, :below => 60.megabytes, :every => 30.seconds, :times => 5
|
19
19
|
start_timeout 30.seconds
|
20
20
|
|
21
21
|
group :web do
|
22
|
-
chain action
|
23
|
-
chain action
|
22
|
+
chain :action => :restart, :grace => 5.seconds
|
23
|
+
chain :action => :start, :grace => 0.2.seconds
|
24
24
|
|
25
25
|
(5555..5560).each do |port|
|
26
26
|
thin self, port
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
29
30
|
end
|
data/examples/triggers.eye
CHANGED
@@ -5,14 +5,15 @@
|
|
5
5
|
# process.execute_sync(cmd, opts)
|
6
6
|
|
7
7
|
Eye.config do
|
8
|
-
logger
|
8
|
+
logger "/tmp/eye.log"
|
9
9
|
end
|
10
10
|
|
11
11
|
Eye.app :triggers do
|
12
|
+
|
12
13
|
# Execute shell command before process start
|
13
14
|
process :a do
|
14
|
-
pid_file
|
15
|
-
start_command
|
15
|
+
pid_file "/tmp/a.pid"
|
16
|
+
start_command "sleep 100"
|
16
17
|
daemonize true
|
17
18
|
|
18
19
|
# send message async which sendxmpp, before process start
|
@@ -23,40 +24,41 @@ Eye.app :triggers do
|
|
23
24
|
|
24
25
|
# Touch some file before process start, remove file after process die
|
25
26
|
process :b do
|
26
|
-
pid_file
|
27
|
-
start_command
|
27
|
+
pid_file "/tmp/b.pid"
|
28
|
+
start_command "sleep 100"
|
28
29
|
daemonize true
|
29
30
|
|
30
31
|
# before process starting, touch some file
|
31
32
|
trigger :transition1, to: :starting, do: -> {
|
32
|
-
process.execute_sync
|
33
|
+
process.execute_sync "touch /tmp/bla.file"
|
33
34
|
}
|
34
35
|
|
35
36
|
# after process, crashed, or stopped, remove that file
|
36
37
|
trigger :transition2, to: :down, do: -> {
|
37
|
-
process.execute_sync
|
38
|
+
process.execute_sync "rm /tmp/bla.file"
|
38
39
|
}
|
39
40
|
end
|
40
41
|
|
41
42
|
# With restart :c process, send restart to process :a
|
42
43
|
process :c do
|
43
|
-
pid_file
|
44
|
-
start_command
|
44
|
+
pid_file "/tmp/c.pid"
|
45
|
+
start_command "sleep 100"
|
45
46
|
daemonize true
|
46
47
|
|
47
48
|
app_name = app.name
|
48
|
-
trigger :transition, event
|
49
|
-
info
|
49
|
+
trigger :transition, :event => :restarting, :do => ->{
|
50
|
+
info "send restarting to :a"
|
50
51
|
Eye::Control.command('restart', "#{app_name}:a")
|
51
52
|
}
|
52
53
|
end
|
53
54
|
|
54
55
|
# process d cant start, until file /tmp/bla contains string 'bla'
|
55
56
|
process :d do
|
56
|
-
pid_file
|
57
|
-
start_command
|
57
|
+
pid_file "/tmp/d.pid"
|
58
|
+
start_command "sleep 100"
|
58
59
|
daemonize true
|
59
60
|
|
60
61
|
trigger :starting_guard, every: 5.seconds, should: -> { `cat /tmp/bla` =~ /bla/ }
|
61
62
|
end
|
63
|
+
|
62
64
|
end
|
data/examples/unicorn.eye
CHANGED
@@ -3,36 +3,37 @@
|
|
3
3
|
RUBY = '/usr/local/ruby/1.9.3/bin/ruby' # ruby on the server
|
4
4
|
RAILS_ENV = 'production'
|
5
5
|
|
6
|
-
Eye.application
|
7
|
-
env
|
6
|
+
Eye.application "rails_unicorn" do
|
7
|
+
env "RAILS_ENV" => RAILS_ENV
|
8
8
|
|
9
9
|
# unicorn requires to be `ruby` in path (for soft restart)
|
10
|
-
env
|
10
|
+
env "PATH" => "#{File.dirname(RUBY)}:#{ENV['PATH']}"
|
11
11
|
|
12
12
|
working_dir File.expand_path(File.join(File.dirname(__FILE__), %w[ processes ]))
|
13
13
|
|
14
|
-
process(
|
15
|
-
pid_file
|
14
|
+
process("unicorn") do
|
15
|
+
pid_file "tmp/pids/unicorn.pid"
|
16
16
|
start_command "#{RUBY} ./bin/unicorn -Dc ./config/unicorn.rb -E #{RAILS_ENV}"
|
17
|
-
stdall
|
17
|
+
stdall "log/unicorn.log"
|
18
18
|
|
19
19
|
# stop signals:
|
20
20
|
# http://unicorn.bogomips.org/SIGNALS.html
|
21
21
|
stop_signals [:TERM, 10.seconds]
|
22
22
|
|
23
23
|
# soft restart
|
24
|
-
restart_command
|
24
|
+
restart_command "kill -USR2 {PID}"
|
25
25
|
|
26
|
-
check :cpu, every
|
27
|
-
check :memory, every
|
26
|
+
check :cpu, :every => 30, :below => 80, :times => 3
|
27
|
+
check :memory, :every => 30, :below => 150.megabytes, :times => [3,5]
|
28
28
|
|
29
29
|
start_timeout 100.seconds
|
30
30
|
restart_grace 30.seconds
|
31
31
|
|
32
32
|
monitor_children do
|
33
|
-
stop_command
|
34
|
-
check :cpu, every
|
35
|
-
check :memory, every
|
33
|
+
stop_command "kill -QUIT {PID}"
|
34
|
+
check :cpu, :every => 30, :below => 80, :times => 3
|
35
|
+
check :memory, :every => 30, :below => 150.megabytes, :times => [3,5]
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
38
39
|
end
|