einhorn 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/einhorn/version.rb +1 -1
- data/lib/einhorn.rb +21 -3
- data/test/integration/_lib/fixtures/exit_during_upgrade/exiting_server.rb +22 -0
- data/test/integration/_lib/fixtures/exit_during_upgrade/upgrade_reexec.rb +6 -0
- data/test/integration/_lib/helpers/einhorn_helpers.rb +1 -1
- data/test/integration/upgrading.rb +29 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4846316f97d2a31a2012b011448d4484bd2b0a10
|
4
|
+
data.tar.gz: 234857a3665289df26b682c744dd0bff01885829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fe4142f182bf1f4af2923b0bbab0b6e12834d6f7a9e55635a313c425266ec7dae0bee52709d733f713103b05f11490a245b7f3bb5db534e2bd5e0560df6608a
|
7
|
+
data.tar.gz: a141cde6246d6df28c0fea3d4db57335d5434ad78932316002c0b9250f2b52dcd3233c4cad6e45e119393144fb0540c1e352c128065d0e982d82895590d70923
|
data/lib/einhorn/version.rb
CHANGED
data/lib/einhorn.rb
CHANGED
@@ -130,11 +130,29 @@ module Einhorn
|
|
130
130
|
message << "upgraded :reloading_for_preload_upgrade to :reloading_for_upgrade"
|
131
131
|
end
|
132
132
|
|
133
|
-
# For a period, we created children entries for state_passers,
|
134
|
-
# but we don't want that (in particular, it probably died before
|
135
|
-
# we could setup our SIGCHLD handler
|
136
133
|
if updated_state[:children]
|
134
|
+
# For a period, we created children entries for state_passers,
|
135
|
+
# but we don't want that (in particular, it probably died
|
136
|
+
# before we could setup our SIGCHLD handler
|
137
137
|
updated_state[:children].delete_if {|k, v| v[:type] == :state_passer}
|
138
|
+
|
139
|
+
# Depending on what is passed for --reexec-as, it's possible
|
140
|
+
# that the process received a SIGCHLD while something other
|
141
|
+
# than einhorn was the active executable. If that happened,
|
142
|
+
# einhorn might not know about a dead child, so let's check
|
143
|
+
# them all
|
144
|
+
dead = []
|
145
|
+
updated_state[:children].each do |pid, v|
|
146
|
+
begin
|
147
|
+
pid = Process.wait(pid, Process::WNOHANG)
|
148
|
+
dead << pid if pid
|
149
|
+
rescue Errno::ECHILD
|
150
|
+
dead << pid
|
151
|
+
end
|
152
|
+
end
|
153
|
+
Einhorn::Event::Timer.open(0) do
|
154
|
+
dead.each {|pid| Einhorn::Command.mourn(pid)}
|
155
|
+
end
|
138
156
|
end
|
139
157
|
end
|
140
158
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'socket'
|
3
|
+
require 'einhorn/worker'
|
4
|
+
|
5
|
+
def einhorn_main
|
6
|
+
serv = Socket.for_fd(Einhorn::Worker.socket!)
|
7
|
+
Einhorn::Worker.ack!
|
8
|
+
|
9
|
+
Signal.trap('USR2') do
|
10
|
+
sleep 3
|
11
|
+
exit!
|
12
|
+
end
|
13
|
+
|
14
|
+
while true
|
15
|
+
s, _ = serv.accept
|
16
|
+
s.write($$)
|
17
|
+
s.flush
|
18
|
+
s.close
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
einhorn_main if $0 == __FILE__
|
@@ -90,7 +90,7 @@ module Helpers
|
|
90
90
|
@fixtured_dirs ||= Set.new
|
91
91
|
new_dir = Dir.mktmpdir(name)
|
92
92
|
@fixtured_dirs << new_dir
|
93
|
-
FileUtils.cp_r(File.join(fixture_path(name), '.'), new_dir)
|
93
|
+
FileUtils.cp_r(File.join(fixture_path(name), '.'), new_dir, :preserve => true)
|
94
94
|
|
95
95
|
new_dir
|
96
96
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require(File.expand_path('_lib', File.dirname(__FILE__)))
|
2
2
|
require 'socket'
|
3
|
+
require 'einhorn/client'
|
3
4
|
|
4
5
|
class UpgradeTests < EinhornIntegrationTestCase
|
5
6
|
include Helpers::EinhornHelpers
|
@@ -53,6 +54,34 @@ class UpgradeTests < EinhornIntegrationTestCase
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
57
|
+
it 'cleans up if a child dies during the reexec' do
|
58
|
+
# attempt to setup a scenario where a child exits in the
|
59
|
+
# interlude after old einhorn has execed the reexec-as
|
60
|
+
# command, but before the reexec-as command execs new einhorn
|
61
|
+
|
62
|
+
@dir = prepare_fixture_directory('exit_during_upgrade')
|
63
|
+
@server_program = File.join(@dir, "exiting_server.rb")
|
64
|
+
@socket_path = File.join(@dir, "einhorn.sock")
|
65
|
+
|
66
|
+
reexec_cmdline = File.join(@dir, 'upgrade_reexec.rb')
|
67
|
+
|
68
|
+
with_running_einhorn(%W{einhorn -m manual -b 127.0.0.1:#{@port} --reexec-as=#{reexec_cmdline} -d #{@socket_path} -- ruby #{@server_program}}) do |process|
|
69
|
+
wait_for_open_port
|
70
|
+
|
71
|
+
Process.kill('USR2', read_from_port.to_i)
|
72
|
+
einhornsh(%W{-d #{@socket_path} -e upgrade})
|
73
|
+
|
74
|
+
client = Einhorn::Client.for_path(@socket_path)
|
75
|
+
client.send_command('command' => 'state')
|
76
|
+
resp = client.receive_message
|
77
|
+
|
78
|
+
state = YAML.load(resp['message'])
|
79
|
+
assert_equal(1, state[:state][:children].count)
|
80
|
+
|
81
|
+
process.terminate
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
56
85
|
describe 'without preloading' do
|
57
86
|
it 'can update environment variables when the reexec command line says to' do
|
58
87
|
# exec the new einhorn with the same environment:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: einhorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Brockman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -150,6 +150,8 @@ files:
|
|
150
150
|
- test/_lib.rb
|
151
151
|
- test/integration/_lib.rb
|
152
152
|
- test/integration/_lib/fixtures/env_printer/env_printer.rb
|
153
|
+
- test/integration/_lib/fixtures/exit_during_upgrade/exiting_server.rb
|
154
|
+
- test/integration/_lib/fixtures/exit_during_upgrade/upgrade_reexec.rb
|
153
155
|
- test/integration/_lib/fixtures/upgrade_project/upgrading_server.rb
|
154
156
|
- test/integration/_lib/helpers.rb
|
155
157
|
- test/integration/_lib/helpers/einhorn_helpers.rb
|
@@ -189,6 +191,8 @@ test_files:
|
|
189
191
|
- test/_lib.rb
|
190
192
|
- test/integration/_lib.rb
|
191
193
|
- test/integration/_lib/fixtures/env_printer/env_printer.rb
|
194
|
+
- test/integration/_lib/fixtures/exit_during_upgrade/exiting_server.rb
|
195
|
+
- test/integration/_lib/fixtures/exit_during_upgrade/upgrade_reexec.rb
|
192
196
|
- test/integration/_lib/fixtures/upgrade_project/upgrading_server.rb
|
193
197
|
- test/integration/_lib/helpers.rb
|
194
198
|
- test/integration/_lib/helpers/einhorn_helpers.rb
|