engineyard-serverside 2.1.4 → 2.2.0.pre
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.
- data/lib/engineyard-serverside.rb +0 -1
- data/lib/engineyard-serverside/cli.rb +32 -13
- data/lib/engineyard-serverside/configuration.rb +1 -1
- data/lib/engineyard-serverside/dependency_manager/composer.rb +2 -2
- data/lib/engineyard-serverside/deploy.rb +3 -4
- data/lib/engineyard-serverside/maintenance.rb +1 -1
- data/lib/engineyard-serverside/rails_assets.rb +8 -3
- data/lib/engineyard-serverside/server.rb +12 -0
- data/lib/engineyard-serverside/servers.rb +32 -27
- data/lib/engineyard-serverside/shell.rb +2 -14
- data/lib/engineyard-serverside/shell/command_result.rb +3 -7
- data/lib/engineyard-serverside/spawner.rb +187 -0
- data/lib/engineyard-serverside/strategies/git.rb +1 -1
- data/lib/engineyard-serverside/task.rb +2 -2
- data/lib/engineyard-serverside/version.rb +1 -1
- data/spec/bundler_deploy_spec.rb +5 -3
- data/spec/deploy_hook_spec.rb +8 -10
- data/spec/git_strategy_spec.rb +1 -1
- data/spec/nodejs_deploy_spec.rb +11 -10
- data/spec/php_deploy_spec.rb +40 -48
- data/spec/server_spec.rb +5 -5
- data/spec/spec_helper.rb +122 -8
- data/spec/support/integration.rb +0 -1
- metadata +10 -24
- data/lib/engineyard-serverside/propagator.rb +0 -75
- data/lib/vendor/systemu/LICENSE +0 -3
- data/lib/vendor/systemu/lib/systemu.rb +0 -363
- data/lib/vendor/systemu/systemu.gemspec +0 -45
- data/spec/propagator_spec.rb +0 -95
data/spec/support/integration.rb
CHANGED
metadata
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard-serverside
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
5
|
-
prerelease:
|
4
|
+
version: 2.2.0.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- EY Cloud Team
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 2.12.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 2.12.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,10 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0
|
38
|
-
- - <
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
37
|
+
version: '0'
|
41
38
|
type: :development
|
42
39
|
prerelease: false
|
43
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -45,10 +42,7 @@ dependencies:
|
|
45
42
|
requirements:
|
46
43
|
- - ! '>='
|
47
44
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0
|
49
|
-
- - <
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '10.0'
|
45
|
+
version: '0'
|
52
46
|
- !ruby/object:Gem::Dependency
|
53
47
|
name: rdoc
|
54
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,7 +164,6 @@ files:
|
|
170
164
|
- lib/engineyard-serverside/deprecation.rb
|
171
165
|
- lib/engineyard-serverside/maintenance.rb
|
172
166
|
- lib/engineyard-serverside/paths.rb
|
173
|
-
- lib/engineyard-serverside/propagator.rb
|
174
167
|
- lib/engineyard-serverside/rails_assets/strategy.rb
|
175
168
|
- lib/engineyard-serverside/rails_assets.rb
|
176
169
|
- lib/engineyard-serverside/server.rb
|
@@ -180,6 +173,7 @@ files:
|
|
180
173
|
- lib/engineyard-serverside/shell/helpers.rb
|
181
174
|
- lib/engineyard-serverside/shell/yieldio.rb
|
182
175
|
- lib/engineyard-serverside/shell.rb
|
176
|
+
- lib/engineyard-serverside/spawner.rb
|
183
177
|
- lib/engineyard-serverside/strategies/git.rb
|
184
178
|
- lib/engineyard-serverside/task.rb
|
185
179
|
- lib/engineyard-serverside/version.rb
|
@@ -209,9 +203,6 @@ files:
|
|
209
203
|
- lib/vendor/multi_json/spec/helper.rb
|
210
204
|
- lib/vendor/multi_json/spec/json_common_shared_example.rb
|
211
205
|
- lib/vendor/multi_json/spec/multi_json_spec.rb
|
212
|
-
- lib/vendor/systemu/lib/systemu.rb
|
213
|
-
- lib/vendor/systemu/LICENSE
|
214
|
-
- lib/vendor/systemu/systemu.gemspec
|
215
206
|
- lib/vendor/thor/bin/rake2thor
|
216
207
|
- lib/vendor/thor/bin/thor
|
217
208
|
- lib/vendor/thor/lib/thor/actions/create_file.rb
|
@@ -376,7 +367,6 @@ files:
|
|
376
367
|
- spec/lockfile_parser_spec.rb
|
377
368
|
- spec/nodejs_deploy_spec.rb
|
378
369
|
- spec/php_deploy_spec.rb
|
379
|
-
- spec/propagator_spec.rb
|
380
370
|
- spec/rails31_deploy_spec.rb
|
381
371
|
- spec/restart_spec.rb
|
382
372
|
- spec/rollback_spec.rb
|
@@ -398,9 +388,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
398
388
|
- - ! '>='
|
399
389
|
- !ruby/object:Gem::Version
|
400
390
|
version: '0'
|
401
|
-
segments:
|
402
|
-
- 0
|
403
|
-
hash: 1955652891792976111
|
404
391
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
405
392
|
none: false
|
406
393
|
requirements:
|
@@ -542,7 +529,6 @@ test_files:
|
|
542
529
|
- spec/lockfile_parser_spec.rb
|
543
530
|
- spec/nodejs_deploy_spec.rb
|
544
531
|
- spec/php_deploy_spec.rb
|
545
|
-
- spec/propagator_spec.rb
|
546
532
|
- spec/rails31_deploy_spec.rb
|
547
533
|
- spec/restart_spec.rb
|
548
534
|
- spec/rollback_spec.rb
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'engineyard-serverside/about'
|
2
|
-
|
3
|
-
module EY
|
4
|
-
module Serverside
|
5
|
-
# Put the same engineyard-serverside on all the servers
|
6
|
-
class Propagator
|
7
|
-
def self.call(*args)
|
8
|
-
new(*args).call
|
9
|
-
end
|
10
|
-
|
11
|
-
attr_reader :config, :shell
|
12
|
-
|
13
|
-
def initialize(servers, config, shell, options={})
|
14
|
-
@remote_servers = servers.remote
|
15
|
-
@config, @shell = config, shell
|
16
|
-
end
|
17
|
-
|
18
|
-
# servers that need to have the gem installed
|
19
|
-
def servers
|
20
|
-
@servers ||= find_servers_missing_gem
|
21
|
-
end
|
22
|
-
|
23
|
-
# Find the servers that need the gem, then install the gem on them
|
24
|
-
def call
|
25
|
-
servers.any? && propagate
|
26
|
-
end
|
27
|
-
|
28
|
-
def remote_gem_file
|
29
|
-
File.join(Dir.tmpdir, About.gem_filename)
|
30
|
-
end
|
31
|
-
|
32
|
-
def gem_binary
|
33
|
-
File.join(Gem.default_bindir, 'gem')
|
34
|
-
end
|
35
|
-
|
36
|
-
# the [,)] is to stop us from looking for e.g. 0.5.1, seeing
|
37
|
-
# 0.5.11, and mistakenly thinking 0.5.1 is there
|
38
|
-
def check_command
|
39
|
-
%{#{gem_binary} list #{About.gem_name} | grep "#{About.gem_name}" | egrep -q "#{About.version.gsub(/\./, '\.')}[,)]"}
|
40
|
-
end
|
41
|
-
|
42
|
-
def scp_command(server)
|
43
|
-
Escape.shell_command([
|
44
|
-
'scp',
|
45
|
-
'-i', config.paths.internal_key.to_s,
|
46
|
-
"-o", "StrictHostKeyChecking=no",
|
47
|
-
About.gem_file,
|
48
|
-
"#{server.authority}:#{remote_gem_file}",
|
49
|
-
])
|
50
|
-
end
|
51
|
-
|
52
|
-
def install_command
|
53
|
-
"#{gem_binary} install --no-rdoc --no-ri '#{remote_gem_file}'"
|
54
|
-
end
|
55
|
-
|
56
|
-
def count_servers(set)
|
57
|
-
"#{set.size} server#{set.size == 1 ? '' : 's'}"
|
58
|
-
end
|
59
|
-
|
60
|
-
def find_servers_missing_gem
|
61
|
-
return @remote_servers if @remote_servers.empty?
|
62
|
-
shell.status "Verifying #{About.name_with_version} on #{count_servers(@remote_servers)}."
|
63
|
-
@remote_servers.select_in_parallel do |server|
|
64
|
-
!shell.logged_system(server.command_on_server('sh -l -c', check_command)).success?
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def propagate
|
69
|
-
shell.status "Propagating #{About.name_with_version} to #{count_servers(servers)}."
|
70
|
-
servers.run_on_each(shell) { |server| shell.logged_system(scp_command(server)) }
|
71
|
-
servers.run_on_each(shell) { |server| shell.logged_system(server.command_on_server('sudo sh -l -c', install_command)) }
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
data/lib/vendor/systemu/LICENSE
DELETED
@@ -1,363 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'tmpdir'
|
4
|
-
require 'socket'
|
5
|
-
require 'fileutils'
|
6
|
-
require 'rbconfig'
|
7
|
-
require 'thread'
|
8
|
-
|
9
|
-
class Object
|
10
|
-
def systemu(*a, &b) SystemUniversal.new(*a, &b).systemu end
|
11
|
-
end
|
12
|
-
|
13
|
-
class SystemUniversal
|
14
|
-
#
|
15
|
-
# constants
|
16
|
-
#
|
17
|
-
SystemUniversal::VERSION = '2.5.0' unless SystemUniversal.send(:const_defined?, :VERSION)
|
18
|
-
def SystemUniversal.version() SystemUniversal::VERSION end
|
19
|
-
def version() SystemUniversal::VERSION end
|
20
|
-
#
|
21
|
-
# class methods
|
22
|
-
#
|
23
|
-
|
24
|
-
@host = Socket.gethostname
|
25
|
-
@ppid = Process.ppid
|
26
|
-
@pid = Process.pid
|
27
|
-
@turd = ENV['SYSTEMU_TURD']
|
28
|
-
|
29
|
-
c = begin; ::RbConfig::CONFIG; rescue NameError; ::Config::CONFIG; end
|
30
|
-
ruby = File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT']
|
31
|
-
@ruby = if system('%s -e 42' % ruby)
|
32
|
-
ruby
|
33
|
-
else
|
34
|
-
system('%s -e 42' % 'ruby') ? 'ruby' : warn('no ruby in PATH/CONFIG')
|
35
|
-
end
|
36
|
-
|
37
|
-
class << SystemUniversal
|
38
|
-
%w( host ppid pid ruby turd ).each{|a| attr_accessor a}
|
39
|
-
|
40
|
-
def quote(*words)
|
41
|
-
words.map{|word| word.inspect}.join(' ')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
#
|
46
|
-
# instance methods
|
47
|
-
#
|
48
|
-
|
49
|
-
def initialize argv, opts = {}, &block
|
50
|
-
getopt = getopts opts
|
51
|
-
|
52
|
-
@argv = argv
|
53
|
-
@block = block
|
54
|
-
|
55
|
-
@stdin = getopt[ ['stdin', 'in', '0', 0] ]
|
56
|
-
@stdout = getopt[ ['stdout', 'out', '1', 1] ]
|
57
|
-
@stderr = getopt[ ['stderr', 'err', '2', 2] ]
|
58
|
-
@env = getopt[ 'env' ]
|
59
|
-
@cwd = getopt[ 'cwd' ]
|
60
|
-
|
61
|
-
@host = getopt[ 'host', self.class.host ]
|
62
|
-
@ppid = getopt[ 'ppid', self.class.ppid ]
|
63
|
-
@pid = getopt[ 'pid', self.class.pid ]
|
64
|
-
@ruby = getopt[ 'ruby', self.class.ruby ]
|
65
|
-
end
|
66
|
-
|
67
|
-
def systemu
|
68
|
-
tmpdir do |tmp|
|
69
|
-
c = child_setup tmp
|
70
|
-
status = nil
|
71
|
-
|
72
|
-
begin
|
73
|
-
thread = nil
|
74
|
-
|
75
|
-
quietly{
|
76
|
-
IO.popen "#{ quote(@ruby) } #{ quote(c['program']) }", 'r+' do |pipe|
|
77
|
-
line = pipe.gets
|
78
|
-
case line
|
79
|
-
when %r/^pid: \d+$/
|
80
|
-
cid = Integer line[%r/\d+/]
|
81
|
-
else
|
82
|
-
begin
|
83
|
-
buf = pipe.read
|
84
|
-
buf = "#{ line }#{ buf }"
|
85
|
-
e = Marshal.load buf
|
86
|
-
raise unless Exception === e
|
87
|
-
raise e
|
88
|
-
rescue
|
89
|
-
raise "wtf?\n#{ buf }\n"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
thread = new_thread cid, @block if @block
|
93
|
-
pipe.read rescue nil
|
94
|
-
end
|
95
|
-
}
|
96
|
-
status = $?
|
97
|
-
ensure
|
98
|
-
if thread
|
99
|
-
begin
|
100
|
-
class << status
|
101
|
-
attr 'thread'
|
102
|
-
end
|
103
|
-
status.instance_eval{ @thread = thread }
|
104
|
-
rescue
|
105
|
-
42
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
if @stdout or @stderr
|
111
|
-
open(c['stdout']){|f| relay f => @stdout} if @stdout
|
112
|
-
open(c['stderr']){|f| relay f => @stderr} if @stderr
|
113
|
-
status
|
114
|
-
else
|
115
|
-
[status, IO.read(c['stdout']), IO.read(c['stderr'])]
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def quote *args, &block
|
121
|
-
SystemUniversal.quote(*args, &block)
|
122
|
-
end
|
123
|
-
|
124
|
-
def new_thread cid, block
|
125
|
-
q = Queue.new
|
126
|
-
Thread.new(cid) do |cid|
|
127
|
-
current = Thread.current
|
128
|
-
current.abort_on_exception = true
|
129
|
-
q.push current
|
130
|
-
block.call cid
|
131
|
-
end
|
132
|
-
q.pop
|
133
|
-
end
|
134
|
-
|
135
|
-
def child_setup tmp
|
136
|
-
stdin = File.expand_path(File.join(tmp, 'stdin'))
|
137
|
-
stdout = File.expand_path(File.join(tmp, 'stdout'))
|
138
|
-
stderr = File.expand_path(File.join(tmp, 'stderr'))
|
139
|
-
program = File.expand_path(File.join(tmp, 'program'))
|
140
|
-
config = File.expand_path(File.join(tmp, 'config'))
|
141
|
-
|
142
|
-
if @stdin
|
143
|
-
open(stdin, 'w'){|f| relay @stdin => f}
|
144
|
-
else
|
145
|
-
FileUtils.touch stdin
|
146
|
-
end
|
147
|
-
FileUtils.touch stdout
|
148
|
-
FileUtils.touch stderr
|
149
|
-
|
150
|
-
c = {}
|
151
|
-
c['argv'] = @argv
|
152
|
-
c['env'] = @env
|
153
|
-
c['cwd'] = @cwd
|
154
|
-
c['stdin'] = stdin
|
155
|
-
c['stdout'] = stdout
|
156
|
-
c['stderr'] = stderr
|
157
|
-
c['program'] = program
|
158
|
-
open(config, 'w'){|f| Marshal.dump(c, f)}
|
159
|
-
|
160
|
-
open(program, 'w'){|f| f.write child_program(config)}
|
161
|
-
|
162
|
-
c
|
163
|
-
end
|
164
|
-
|
165
|
-
def quietly
|
166
|
-
v = $VERBOSE
|
167
|
-
$VERBOSE = nil
|
168
|
-
yield
|
169
|
-
ensure
|
170
|
-
$VERBOSE = v
|
171
|
-
end
|
172
|
-
|
173
|
-
def child_program config
|
174
|
-
<<-program
|
175
|
-
# encoding: utf-8
|
176
|
-
|
177
|
-
PIPE = STDOUT.dup
|
178
|
-
begin
|
179
|
-
config = Marshal.load(IO.read('#{ config }'))
|
180
|
-
|
181
|
-
argv = config['argv']
|
182
|
-
env = config['env']
|
183
|
-
cwd = config['cwd']
|
184
|
-
stdin = config['stdin']
|
185
|
-
stdout = config['stdout']
|
186
|
-
stderr = config['stderr']
|
187
|
-
|
188
|
-
Dir.chdir cwd if cwd
|
189
|
-
env.each{|k,v| ENV[k.to_s] = v.to_s} if env
|
190
|
-
|
191
|
-
STDIN.reopen stdin
|
192
|
-
STDOUT.reopen stdout
|
193
|
-
STDERR.reopen stderr
|
194
|
-
|
195
|
-
PIPE.puts "pid: \#{ Process.pid }"
|
196
|
-
PIPE.flush ### the process is ready yo!
|
197
|
-
PIPE.close
|
198
|
-
if RUBY_VERSION >= "1.9"
|
199
|
-
exec *argv
|
200
|
-
else
|
201
|
-
exec argv
|
202
|
-
end
|
203
|
-
rescue Exception => e
|
204
|
-
PIPE.write Marshal.dump(e) rescue nil
|
205
|
-
exit 42
|
206
|
-
end
|
207
|
-
program
|
208
|
-
end
|
209
|
-
|
210
|
-
def relay srcdst
|
211
|
-
src, dst, ignored = srcdst.to_a.first
|
212
|
-
if src.respond_to? 'read'
|
213
|
-
while((buf = src.read(8192))); dst << buf; end
|
214
|
-
else
|
215
|
-
if src.respond_to?(:each_line)
|
216
|
-
src.each_line{|buf| dst << buf}
|
217
|
-
else
|
218
|
-
src.each{|buf| dst << buf}
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
def tmpdir d = Dir.tmpdir, max = 42, &b
|
224
|
-
i = -1 and loop{
|
225
|
-
i += 1
|
226
|
-
|
227
|
-
tmp = File.join d, "systemu_#{ @host }_#{ @ppid }_#{ @pid }_#{ rand }_#{ i += 1 }"
|
228
|
-
|
229
|
-
begin
|
230
|
-
Dir.mkdir tmp
|
231
|
-
rescue Errno::EEXIST
|
232
|
-
raise if i >= max
|
233
|
-
next
|
234
|
-
end
|
235
|
-
|
236
|
-
break(
|
237
|
-
if b
|
238
|
-
begin
|
239
|
-
b.call tmp
|
240
|
-
ensure
|
241
|
-
FileUtils.rm_rf tmp unless SystemU.turd
|
242
|
-
end
|
243
|
-
else
|
244
|
-
tmp
|
245
|
-
end
|
246
|
-
)
|
247
|
-
}
|
248
|
-
end
|
249
|
-
|
250
|
-
def getopts opts = {}
|
251
|
-
lambda do |*args|
|
252
|
-
keys, default, ignored = args
|
253
|
-
catch(:opt) do
|
254
|
-
[keys].flatten.each do |key|
|
255
|
-
[key, key.to_s, key.to_s.intern].each do |key|
|
256
|
-
throw :opt, opts[key] if opts.has_key?(key)
|
257
|
-
end
|
258
|
-
end
|
259
|
-
default
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
# some monkeypatching for JRuby
|
266
|
-
if defined? JRUBY_VERSION
|
267
|
-
require 'jruby'
|
268
|
-
java_import org.jruby.RubyProcess
|
269
|
-
|
270
|
-
class SystemUniversal
|
271
|
-
def systemu
|
272
|
-
split_argv = JRuby::PathHelper.smart_split_command @argv
|
273
|
-
process = java.lang.Runtime.runtime.exec split_argv.to_java(:string)
|
274
|
-
|
275
|
-
stdout, stderr = [process.input_stream, process.error_stream].map do |stream|
|
276
|
-
StreamReader.new(stream)
|
277
|
-
end
|
278
|
-
|
279
|
-
exit_code = process.wait_for
|
280
|
-
field = process.get_class.get_declared_field("pid")
|
281
|
-
field.set_accessible(true)
|
282
|
-
pid = field.get(process)
|
283
|
-
[
|
284
|
-
RubyProcess::RubyStatus.new_process_status(JRuby.runtime, exit_code, pid),
|
285
|
-
stdout.join,
|
286
|
-
stderr.join
|
287
|
-
]
|
288
|
-
end
|
289
|
-
|
290
|
-
class StreamReader
|
291
|
-
def initialize(stream)
|
292
|
-
@data = ""
|
293
|
-
@thread = Thread.new do
|
294
|
-
reader = java.io.BufferedReader.new java.io.InputStreamReader.new(stream)
|
295
|
-
|
296
|
-
while line = reader.read_line
|
297
|
-
@data << line << "\n"
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
def join
|
303
|
-
@thread.join
|
304
|
-
@data
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
SystemU = SystemUniversal unless defined? SystemU
|
313
|
-
Systemu = SystemUniversal unless defined? Systemu
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
if $0 == __FILE__
|
328
|
-
#
|
329
|
-
# date
|
330
|
-
#
|
331
|
-
date = %q( ruby -e" t = Time.now; STDOUT.puts t; STDERR.puts t " )
|
332
|
-
|
333
|
-
status, stdout, stderr = systemu date
|
334
|
-
p [status, stdout, stderr]
|
335
|
-
|
336
|
-
status = systemu date, 1=>(stdout = '')
|
337
|
-
p [status, stdout]
|
338
|
-
|
339
|
-
status = systemu date, 2=>(stderr = '')
|
340
|
-
p [status, stderr]
|
341
|
-
#
|
342
|
-
# sleep
|
343
|
-
#
|
344
|
-
sleep = %q( ruby -e" p(sleep(1)) " )
|
345
|
-
status, stdout, stderr = systemu sleep
|
346
|
-
p [status, stdout, stderr]
|
347
|
-
|
348
|
-
sleep = %q( ruby -e" p(sleep(42)) " )
|
349
|
-
status, stdout, stderr = systemu(sleep){|cid| Process.kill 9, cid}
|
350
|
-
p [status, stdout, stderr]
|
351
|
-
#
|
352
|
-
# env
|
353
|
-
#
|
354
|
-
env = %q( ruby -e" p ENV['A'] " )
|
355
|
-
status, stdout, stderr = systemu env, :env => {'A' => 42}
|
356
|
-
p [status, stdout, stderr]
|
357
|
-
#
|
358
|
-
# cwd
|
359
|
-
#
|
360
|
-
env = %q( ruby -e" p Dir.pwd " )
|
361
|
-
status, stdout, stderr = systemu env, :cwd => Dir.tmpdir
|
362
|
-
p [status, stdout, stderr]
|
363
|
-
end
|