engineyard-serverside 1.5.30 → 1.5.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module Serverside
3
- VERSION = '1.5.30'
3
+ VERSION = '1.5.32'
4
4
  end
5
5
  end
@@ -4,65 +4,23 @@ require 'timeout'
4
4
  require 'thread'
5
5
 
6
6
  module Open4
7
- VERSION = '1.3.0'
7
+ #--{{{
8
+ VERSION = '1.1.0'
8
9
  def self.version() VERSION end
9
10
 
10
11
  class Error < ::StandardError; end
11
12
 
12
- def pfork4(fun, &b)
13
- Open4.do_popen(b, :block) do |ps_read, _|
14
- ps_read.close
15
- begin
16
- fun.call
17
- rescue SystemExit => e
18
- # Make it seem to the caller that calling Kernel#exit in +fun+ kills
19
- # the child process normally. Kernel#exit! bypasses this rescue
20
- # block.
21
- exit! e.status
22
- else
23
- exit! 0
24
- end
25
- end
26
- end
27
- module_function :pfork4
28
-
29
13
  def popen4(*cmd, &b)
30
- Open4.do_popen(b, :init) do |ps_read, ps_write|
31
- ps_read.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
32
- ps_write.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
33
- exec(*cmd)
34
- raise 'forty-two' # Is this really needed?
35
- end
36
- end
37
- alias open4 popen4
38
- module_function :popen4
39
- module_function :open4
40
-
41
- def popen4ext(closefds=false, *cmd, &b)
42
- Open4.do_popen(b, :init, closefds) do |ps_read, ps_write|
43
- ps_read.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
44
- ps_write.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
45
- exec(*cmd)
46
- raise 'forty-two' # Is this really needed?
47
- end
48
- end
49
- module_function :popen4ext
50
-
51
- def self.do_popen(b = nil, exception_propagation_at = nil, closefds=false, &cmd)
14
+ #--{{{
52
15
  pw, pr, pe, ps = IO.pipe, IO.pipe, IO.pipe, IO.pipe
53
16
 
54
17
  verbose = $VERBOSE
55
18
  begin
56
19
  $VERBOSE = nil
20
+ ps.first.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
21
+ ps.last.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
57
22
 
58
23
  cid = fork {
59
- if closefds
60
- exlist = [0, 1, 2] | [pw,pr,pe,ps].map{|p| [p.first.fileno, p.last.fileno] }.flatten
61
- ObjectSpace.each_object(IO){|io|
62
- io.close if (not io.closed?) and (not exlist.include? io.fileno)
63
- }
64
- end
65
-
66
24
  pw.last.close
67
25
  STDIN.reopen pw.first
68
26
  pw.first.close
@@ -78,59 +36,52 @@ module Open4
78
36
  STDOUT.sync = STDERR.sync = true
79
37
 
80
38
  begin
81
- cmd.call(ps)
39
+ exec(*cmd)
40
+ raise 'forty-two'
82
41
  rescue Exception => e
83
42
  Marshal.dump(e, ps.last)
84
43
  ps.last.flush
85
- ensure
86
- ps.last.close unless ps.last.closed?
87
44
  end
88
-
45
+ ps.last.close unless (ps.last.closed?)
89
46
  exit!
90
47
  }
91
48
  ensure
92
49
  $VERBOSE = verbose
93
50
  end
94
51
 
95
- [ pw.first, pr.last, pe.last, ps.last ].each { |fd| fd.close }
52
+ [pw.first, pr.last, pe.last, ps.last].each{|fd| fd.close}
96
53
 
97
- Open4.propagate_exception cid, ps.first if exception_propagation_at == :init
54
+ begin
55
+ e = Marshal.load ps.first
56
+ raise(Exception === e ? e : "unknown failure!")
57
+ rescue EOFError # If we get an EOF error, then the exec was successful
58
+ 42
59
+ ensure
60
+ ps.first.close
61
+ end
98
62
 
99
63
  pw.last.sync = true
100
64
 
101
- pi = [ pw.last, pr.first, pe.first ]
102
-
103
- begin
104
- return [cid, *pi] unless b
65
+ pi = [pw.last, pr.first, pe.first]
105
66
 
67
+ if b
106
68
  begin
107
- b.call(cid, *pi)
69
+ b[cid, *pi]
70
+ Process.waitpid2(cid).last
108
71
  ensure
109
- pi.each { |fd| fd.close unless fd.closed? }
72
+ pi.each{|fd| fd.close unless fd.closed?}
110
73
  end
111
-
112
- Open4.propagate_exception cid, ps.first if exception_propagation_at == :block
113
-
114
- Process.waitpid2(cid).last
115
- ensure
116
- ps.first.close unless ps.first.closed?
74
+ else
75
+ [cid, pw.last, pr.first, pe.first]
117
76
  end
77
+ #--}}}
118
78
  end
119
-
120
- def self.propagate_exception(cid, ps_read)
121
- e = Marshal.load ps_read
122
- raise Exception === e ? e : "unknown failure!"
123
- rescue EOFError
124
- # Child process did not raise exception.
125
- rescue
126
- # Child process raised exception; wait it in order to avoid a zombie.
127
- Process.waitpid2 cid
128
- raise
129
- ensure
130
- ps_read.close
131
- end
79
+ alias open4 popen4
80
+ module_function :popen4
81
+ module_function :open4
132
82
 
133
83
  class SpawnError < Error
84
+ #--{{{
134
85
  attr 'cmd'
135
86
  attr 'status'
136
87
  attr 'signals'
@@ -147,9 +98,11 @@ module Open4
147
98
  sigs = @signals.map{|k,v| "#{ k }:#{ v.inspect }"}.join(' ')
148
99
  super "cmd <#{ cmd }> failed with status <#{ exitstatus.inspect }> signals <#{ sigs }>"
149
100
  end
101
+ #--}}}
150
102
  end
151
103
 
152
104
  class ThreadEnsemble
105
+ #--{{{
153
106
  attr 'threads'
154
107
 
155
108
  def initialize cid
@@ -201,14 +154,18 @@ module Open4
201
154
  def all_done
202
155
  @threads.size.times{ @done.pop }
203
156
  end
157
+ #--}}}
204
158
  end
205
159
 
206
160
  def to timeout = nil
161
+ #--{{{
207
162
  Timeout.timeout(timeout){ yield }
163
+ #--}}}
208
164
  end
209
165
  module_function :to
210
166
 
211
167
  def new_thread *a, &b
168
+ #--{{{
212
169
  cur = Thread.current
213
170
  Thread.new(*a) do |*a|
214
171
  begin
@@ -217,25 +174,29 @@ module Open4
217
174
  cur.raise e
218
175
  end
219
176
  end
177
+ #--}}}
220
178
  end
221
179
  module_function :new_thread
222
180
 
223
181
  def getopts opts = {}
182
+ #--{{{
224
183
  lambda do |*args|
225
184
  keys, default, ignored = args
226
- catch(:opt) do
185
+ catch('opt') do
227
186
  [keys].flatten.each do |key|
228
187
  [key, key.to_s, key.to_s.intern].each do |key|
229
- throw :opt, opts[key] if opts.has_key?(key)
188
+ throw 'opt', opts[key] if opts.has_key?(key)
230
189
  end
231
190
  end
232
191
  default
233
192
  end
234
193
  end
194
+ #--}}}
235
195
  end
236
196
  module_function :getopts
237
197
 
238
198
  def relay src, dst = nil, t = nil
199
+ #--{{{
239
200
  send_dst =
240
201
  if dst.respond_to?(:call)
241
202
  lambda{|buf| dst.call(buf)}
@@ -283,10 +244,12 @@ module Open4
283
244
  send_dst[buf]
284
245
  end
285
246
  end
247
+ #--}}}
286
248
  end
287
249
  module_function :relay
288
250
 
289
251
  def spawn arg, *argv
252
+ #--{{{
290
253
  argv.unshift(arg)
291
254
  opts = ((argv.size > 1 and Hash === argv.last) ? argv.pop : {})
292
255
  argv.flatten!
@@ -362,6 +325,7 @@ module Open4
362
325
  (ignore_exit_failure or (status.nil? and ignore_exec_failure) or exitstatus.include?(status.exitstatus))
363
326
 
364
327
  status
328
+ #--}}}
365
329
  end
366
330
  module_function :spawn
367
331
 
@@ -372,6 +336,7 @@ module Open4
372
336
  module_function :chdir
373
337
 
374
338
  def background arg, *argv
339
+ #--{{{
375
340
  require 'thread'
376
341
  q = Queue.new
377
342
  opts = { 'pid' => q, :pid => q }
@@ -389,12 +354,14 @@ module Open4
389
354
  define_method(:exitstatus){ @exitstatus ||= spawn_status.exitstatus }
390
355
  }
391
356
  thread
357
+ #--}}}
392
358
  end
393
359
  alias bg background
394
360
  module_function :background
395
361
  module_function :bg
396
362
 
397
363
  def maim pid, opts = {}
364
+ #--{{{
398
365
  getopt = getopts opts
399
366
  sigs = getopt[ 'signals', %w(SIGTERM SIGQUIT SIGKILL) ]
400
367
  suspend = getopt[ 'suspend', 4 ]
@@ -412,10 +379,12 @@ module Open4
412
379
  return true unless alive? pid
413
380
  end
414
381
  return(not alive?(pid))
382
+ #--}}}
415
383
  end
416
384
  module_function :maim
417
385
 
418
386
  def alive pid
387
+ #--{{{
419
388
  pid = Integer pid
420
389
  begin
421
390
  Process.kill 0, pid
@@ -423,10 +392,12 @@ module Open4
423
392
  rescue Errno::ESRCH
424
393
  false
425
394
  end
395
+ #--}}}
426
396
  end
427
397
  alias alive? alive
428
398
  module_function :alive
429
399
  module_function :'alive?'
400
+ #--}}}
430
401
  end
431
402
 
432
403
  def open4(*cmd, &b) cmd.size == 0 ? Open4 : Open4::popen4(*cmd, &b) end
metadata CHANGED
@@ -1,92 +1,87 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: engineyard-serverside
3
- version: !ruby/object:Gem::Version
4
- hash: 63
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.32
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 5
9
- - 30
10
- version: 1.5.30
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - EY Cloud Team
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-02-29 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
12
+ date: 2012-03-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
22
17
  none: false
23
- requirements:
24
- - - "="
25
- - !ruby/object:Gem::Version
26
- hash: 31
27
- segments:
28
- - 1
29
- - 3
30
- - 2
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
31
21
  version: 1.3.2
32
- prerelease: false
33
- requirement: *id001
34
22
  type: :development
35
- name: rspec
36
- - !ruby/object:Gem::Dependency
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 11
43
- segments:
44
- - 0
45
- - 9
46
- - 2
47
- - 2
48
- version: 0.9.2.2
49
23
  prerelease: false
50
- requirement: *id002
51
- type: :development
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.3.2
30
+ - !ruby/object:Gem::Dependency
52
31
  name: rake
53
- - !ruby/object:Gem::Dependency
54
- version_requirements: &id003 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
55
33
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
63
- prerelease: false
64
- requirement: *id003
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.9.2.2
65
38
  type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.2.2
46
+ - !ruby/object:Gem::Dependency
66
47
  name: rdoc
67
- - !ruby/object:Gem::Dependency
68
- version_requirements: &id004 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
69
49
  none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
75
- - 0
76
- version: "0"
77
- prerelease: false
78
- requirement: *id004
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
79
54
  type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
80
63
  name: timecop
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
81
78
  description:
82
79
  email: cloud@engineyard.com
83
- executables:
80
+ executables:
84
81
  - engineyard-serverside
85
82
  extensions: []
86
-
87
83
  extra_rdoc_files: []
88
-
89
- files:
84
+ files:
90
85
  - bin/engineyard-serverside
91
86
  - lib/engineyard-serverside/cli.rb
92
87
  - lib/engineyard-serverside/configuration.rb
@@ -326,8 +321,6 @@ files:
326
321
  - spec/deploy_hook_spec.rb
327
322
  - spec/deprecation_spec.rb
328
323
  - spec/fixtures/gemfiles/1.0.21-rails-31-with-sqlite
329
- - spec/fixtures/gitrepo/bar
330
- - spec/fixtures/gitrepo/foo
331
324
  - spec/fixtures/gitrepo.tar.gz
332
325
  - spec/fixtures/invalid_hook.rb
333
326
  - spec/fixtures/lockfiles/0.9-no-bundler
@@ -358,48 +351,38 @@ files:
358
351
  - spec/support/integration.rb
359
352
  homepage: http://github.com/engineyard/engineyard-serverside
360
353
  licenses: []
361
-
362
354
  post_install_message:
363
355
  rdoc_options: []
364
-
365
- require_paths:
356
+ require_paths:
366
357
  - lib
367
- required_ruby_version: !ruby/object:Gem::Requirement
358
+ required_ruby_version: !ruby/object:Gem::Requirement
368
359
  none: false
369
- requirements:
370
- - - ">="
371
- - !ruby/object:Gem::Version
372
- hash: 3
373
- segments:
360
+ requirements:
361
+ - - ! '>='
362
+ - !ruby/object:Gem::Version
363
+ version: '0'
364
+ segments:
374
365
  - 0
375
- version: "0"
376
- required_rubygems_version: !ruby/object:Gem::Requirement
366
+ hash: 3428567106811631275
367
+ required_rubygems_version: !ruby/object:Gem::Requirement
377
368
  none: false
378
- requirements:
379
- - - ">="
380
- - !ruby/object:Gem::Version
381
- hash: 23
382
- segments:
383
- - 1
384
- - 3
385
- - 6
369
+ requirements:
370
+ - - ! '>='
371
+ - !ruby/object:Gem::Version
386
372
  version: 1.3.6
387
373
  requirements: []
388
-
389
374
  rubyforge_project:
390
- rubygems_version: 1.8.15
375
+ rubygems_version: 1.8.19
391
376
  signing_key:
392
377
  specification_version: 3
393
378
  summary: A gem that deploys ruby applications on EY Cloud instances
394
- test_files:
379
+ test_files:
395
380
  - spec/basic_deploy_spec.rb
396
381
  - spec/bundler_deploy_spec.rb
397
382
  - spec/custom_deploy_spec.rb
398
383
  - spec/deploy_hook_spec.rb
399
384
  - spec/deprecation_spec.rb
400
385
  - spec/fixtures/gemfiles/1.0.21-rails-31-with-sqlite
401
- - spec/fixtures/gitrepo/bar
402
- - spec/fixtures/gitrepo/foo
403
386
  - spec/fixtures/gitrepo.tar.gz
404
387
  - spec/fixtures/invalid_hook.rb
405
388
  - spec/fixtures/lockfiles/0.9-no-bundler
File without changes
File without changes