upstart-unicorn-launcher 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/upstart-unicorn-launcher +4 -0
- data/lib/upstart_unicorn_launcher.rb +7 -2
- data/lib/upstart_unicorn_launcher/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcfcecdaacbb99d28cb3ba75e37e0f2f77aa7180
|
4
|
+
data.tar.gz: 7f9384d07859a01267cfc0e3e00b10e2825aa10e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 264cfee8d9ba752f70a878de25dbcd19716c1dfd858dbb66832e9bdc00f6857432719edf9b00320e78918897e0a1b5e66258dd6bf109aba88bc389b3a6de4b30
|
7
|
+
data.tar.gz: 599e9ce3cc01913b01b96ea04e3dfefba648662aba7aaa2f3625c1044effaa58a4e0c4a14801f00abe48d411af274ddfba06493f774f414aff678bce4638e5f4
|
@@ -16,6 +16,10 @@ OptionParser.new do |opts|
|
|
16
16
|
opts.on("-s", "--startup-time STARTUP", "Time to wait for server to start") do |time|
|
17
17
|
options[:startup] = time.to_i
|
18
18
|
end
|
19
|
+
|
20
|
+
opts.on("-v", "--verbose", "Verbose output") do
|
21
|
+
options[:verbose] = true
|
22
|
+
end
|
19
23
|
end.parse!(ARGV[0...command_index])
|
20
24
|
|
21
25
|
launcher = UpstartUnicornLauncher.new command, options
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'timeout'
|
2
2
|
|
3
3
|
class UpstartUnicornLauncher
|
4
|
-
attr_accessor :command, :pidfile, :startup_period, :tick_period, :restarting
|
4
|
+
attr_accessor :command, :pidfile, :startup_period, :tick_period, :restarting, :verbose
|
5
5
|
|
6
6
|
def initialize(command, options = {})
|
7
7
|
self.command = command
|
8
8
|
self.pidfile = File.expand_path(options[:pidfile] || 'unicorn.pid')
|
9
9
|
self.startup_period = options[:startup] || 60
|
10
10
|
self.tick_period = options[:tick] || 0.1
|
11
|
+
self.verbose = options[:verbose] || false
|
11
12
|
end
|
12
13
|
|
13
14
|
def start
|
@@ -32,6 +33,7 @@ class UpstartUnicornLauncher
|
|
32
33
|
|
33
34
|
def restart_server_on(*signals)
|
34
35
|
signals.each do |signal|
|
36
|
+
debug "Received #{signal}, restarting server"
|
35
37
|
trap(signal.to_s) { restart_server }
|
36
38
|
end
|
37
39
|
end
|
@@ -39,6 +41,7 @@ class UpstartUnicornLauncher
|
|
39
41
|
def quit_server_on(*signals)
|
40
42
|
signals.each do |signal|
|
41
43
|
trap(signal.to_s) do
|
44
|
+
debug "Received #{signal}, quitting server"
|
42
45
|
Process.kill signal.to_s, pid
|
43
46
|
wait_until_server_quits
|
44
47
|
exit
|
@@ -97,7 +100,9 @@ class UpstartUnicornLauncher
|
|
97
100
|
private
|
98
101
|
|
99
102
|
def debug(message)
|
100
|
-
|
103
|
+
if verbose
|
104
|
+
puts message
|
105
|
+
end
|
101
106
|
end
|
102
107
|
|
103
108
|
def wait_for(timeout = 20, &block)
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,7 @@ module ProjectSupport
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def start_launcher
|
7
|
-
@launcher_pid = Process.spawn "upstart-unicorn-launcher -s 1 -p spec/templates/test/unicorn.pid -- unicorn -p 7516 -c spec/templates/test/unicorn.rb spec/templates/test/config.ru"
|
7
|
+
@launcher_pid = Process.spawn "upstart-unicorn-launcher -v -s 1 -p spec/templates/test/unicorn.pid -- unicorn -p 7516 -c spec/templates/test/unicorn.rb spec/templates/test/config.ru"
|
8
8
|
sleep 1
|
9
9
|
puts "Launched upstart-unicorn-launcher with PID #{@launcher_pid}"
|
10
10
|
end
|