einhorn 0.7.3 → 0.7.4

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.
@@ -70,12 +70,6 @@ module Einhorn
70
70
  :signal_timeout => nil,
71
71
  }
72
72
  end
73
-
74
- def self.dumpable_state
75
- dump = state
76
- dump[:reloading_for_preload_upgrade] = dump[:reloading_for_upgrade]
77
- dump
78
- end
79
73
  end
80
74
 
81
75
  module TransientState
@@ -110,38 +104,24 @@ module Einhorn
110
104
  updated_state = old_state.dup
111
105
 
112
106
  # Handle changes in state format updates from previous einhorn versions
113
- if store == Einhorn::State
114
- # TODO: Drop this backwards compatibility hack when we hit 0.7
115
- if updated_state.include?(:reloading_for_preload_upgrade) &&
116
- !updated_state.include?(:reloading_for_upgrade)
117
- updated_state[:reloading_for_upgrade] = updated_state.delete(:reloading_for_preload_upgrade)
118
- message << "upgraded :reloading_for_preload_upgrade to :reloading_for_upgrade"
119
- end
120
-
121
- if updated_state[:children]
122
- # For a period, we created children entries for state_passers,
123
- # but we don't want that (in particular, it probably died
124
- # before we could setup our SIGCHLD handler
125
- updated_state[:children].delete_if {|k, v| v[:type] == :state_passer}
126
-
127
- # Depending on what is passed for --reexec-as, it's possible
128
- # that the process received a SIGCHLD while something other
129
- # than einhorn was the active executable. If that happened,
130
- # einhorn might not know about a dead child, so let's check
131
- # them all
132
- dead = []
133
- updated_state[:children].each do |pid, v|
134
- begin
135
- pid = Process.wait(pid, Process::WNOHANG)
136
- dead << pid if pid
137
- rescue Errno::ECHILD
138
- dead << pid
139
- end
140
- end
141
- Einhorn::Event::Timer.open(0) do
142
- dead.each {|pid| Einhorn::Command.mourn(pid)}
107
+ if store == Einhorn::State && updated_state[:children]
108
+ # Depending on what is passed for --reexec-as, it's possible
109
+ # that the process received a SIGCHLD while something other
110
+ # than einhorn was the active executable. If that happened,
111
+ # einhorn might not know about a dead child, so let's check
112
+ # them all
113
+ dead = []
114
+ updated_state[:children].each do |pid, v|
115
+ begin
116
+ pid = Process.wait(pid, Process::WNOHANG)
117
+ dead << pid if pid
118
+ rescue Errno::ECHILD
119
+ dead << pid
143
120
  end
144
121
  end
122
+ Einhorn::Event::Timer.open(0) do
123
+ dead.each {|pid| Einhorn::Command.mourn(pid)}
124
+ end
145
125
  end
146
126
 
147
127
  default = store.default_state
@@ -40,6 +40,8 @@ module Einhorn
40
40
  case type = spec[:type]
41
41
  when :worker
42
42
  Einhorn.log_info("===> Exited worker #{pid.inspect}#{extra}", :upgrade)
43
+ when :state_passer
44
+ Einhorn.log_debug("===> Exited state passing process #{pid.inspect}", :upgrade)
43
45
  else
44
46
  Einhorn.log_error("===> Exited process #{pid.inspect} has unrecgonized type #{type.inspect}: #{spec.inspect}", :upgrade)
45
47
  end
@@ -218,6 +220,7 @@ module Einhorn
218
220
 
219
221
  fork do
220
222
  Einhorn::TransientState.whatami = :state_passer
223
+ Einhorn::State.children[Process.pid] = {type: :state_passer}
221
224
  Einhorn::State.generation += 1
222
225
  read.close
223
226
 
@@ -1,3 +1,3 @@
1
1
  module Einhorn
2
- VERSION = '0.7.3'
2
+ VERSION = '0.7.4'
3
3
  end
@@ -40,28 +40,28 @@ module Helpers
40
40
  begin
41
41
  stdout, stderr = process.communicate
42
42
  rescue Errno::ECHILD
43
- # It's dead, and we're not getting anything. This is
44
- # peaceful.
43
+ # It's dead, and we're not getting anything. This is peaceful.
45
44
  end
46
45
  end
47
46
  yield(process) if block_given?
48
- rescue Exception => e
47
+ rescue
49
48
  unless (status = process.poll) && status.exited?
50
49
  process.terminate
51
50
  end
52
51
  raise
53
52
  ensure
54
53
  unless (status = process.poll) && status.exited?
55
- begin
56
- Timeout.timeout(10) do # (Argh, I'm so sorry)
57
- status = process.wait
54
+ for i in 1..10 do
55
+ status = process.poll
56
+ if status && status.exited?
57
+ break
58
58
  end
59
- rescue Timeout::Error
59
+ sleep(1)
60
+ end
61
+ unless status && status.exited?
60
62
  $stderr.puts "Could not get Einhorn to quit within 10 seconds, killing it forcefully..."
61
63
  process.send_signal("KILL")
62
64
  status = process.wait
63
- rescue Errno::ECHILD
64
- # Process is dead!
65
65
  end
66
66
  end
67
67
  communicator.join
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: einhorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-11 00:00:00.000000000 Z
12
+ date: 2016-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -198,7 +198,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
198
  version: '0'
199
199
  segments:
200
200
  - 0
201
- hash: -3456360524100968279
201
+ hash: 4291999791412545660
202
202
  required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  none: false
204
204
  requirements:
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  version: '0'
208
208
  segments:
209
209
  - 0
210
- hash: -3456360524100968279
210
+ hash: 4291999791412545660
211
211
  requirements: []
212
212
  rubyforge_project:
213
213
  rubygems_version: 1.8.23