easy-serve 0.13 → 0.14
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.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/examples/remote-multi-server.rb +1 -1
- data/lib/easy-serve.rb +18 -18
- data/lib/easy-serve/remote/drb.rb +7 -7
- data/lib/easy-serve/remote/eval-mgr.rb +3 -3
- data/lib/easy-serve/remote/run-mgr.rb +3 -3
- data/lib/easy-serve/service.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54d0c42681120ccf4085716d6641aadb098b1dbd
|
4
|
+
data.tar.gz: 92dd12a3d68e9f19a6f42eb19cac6c9bf587cf30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7744d002ccd22b05fb35f1b6fa6cd54c0ae0f7b75acb36a453f813b93c383f7b15dcbc0093e768925ef34532217cdf58ac2d71b1e504b27204029a84aba2503
|
7
|
+
data.tar.gz: 13333b4f50f55c7b8ec5a7c2f9c57908ca637abf2500a799f1d2e05f757cfaf05ebb76c5008710531c7d13255b2eb75a1cd4fc24b1058e24c6cda00984f9ec87
|
data/README.md
CHANGED
@@ -21,6 +21,8 @@ EasyServe takes the headache out of:
|
|
21
21
|
|
22
22
|
* Working around poor support for dynamic port forwarding in old versions of OpenSSH.
|
23
23
|
|
24
|
+
* Working around a race condition in an old version of OpenSSH.
|
25
|
+
|
24
26
|
* Choosing between -L and -R styles of tunneling, depending on whether the remote process starts independently of the services.
|
25
27
|
|
26
28
|
* Avoiding race conditions in the service setup phase.
|
@@ -108,5 +108,5 @@ EasyServe.start do |ez|
|
|
108
108
|
# Note use of \#{} to interpolate variables that are only available
|
109
109
|
# in the binding where the code is eval-ed. Alternately, use
|
110
110
|
# eval: %Q{...}
|
111
|
-
# but then interpolation from this script is not
|
111
|
+
# but then interpolation from this script is not possible.
|
112
112
|
end
|
data/lib/easy-serve.rb
CHANGED
@@ -6,7 +6,7 @@ require 'fileutils'
|
|
6
6
|
require 'easy-serve/service'
|
7
7
|
|
8
8
|
class EasyServe
|
9
|
-
VERSION = "0.
|
9
|
+
VERSION = "0.14"
|
10
10
|
|
11
11
|
class ServicesExistError < RuntimeError; end
|
12
12
|
|
@@ -23,7 +23,7 @@ class EasyServe
|
|
23
23
|
log.formatter = EasyFormatter.new
|
24
24
|
log
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def self.null_logger
|
28
28
|
log = Logger.new('/dev/null')
|
29
29
|
log.level = Logger::FATAL
|
@@ -38,7 +38,7 @@ class EasyServe
|
|
38
38
|
|
39
39
|
# True means do not propagate ^C to child processes.
|
40
40
|
attr_reader :interactive
|
41
|
-
|
41
|
+
|
42
42
|
# Is this a sibling process, started by the same parent process that
|
43
43
|
# started the services, even if started remotely?
|
44
44
|
# Implies not owner, but not conversely.
|
@@ -84,7 +84,7 @@ class EasyServe
|
|
84
84
|
@ssh_sessions = []
|
85
85
|
@tmpdir = nil
|
86
86
|
@services = opts[:services] # name => service
|
87
|
-
|
87
|
+
|
88
88
|
unless services
|
89
89
|
if services_file
|
90
90
|
@services =
|
@@ -115,14 +115,14 @@ class EasyServe
|
|
115
115
|
def load_service_table_from_io io
|
116
116
|
YAML.load(io).tap {@sibling = false}
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
def init_service_table
|
120
120
|
@services ||= begin
|
121
121
|
@owner = true
|
122
122
|
{}
|
123
123
|
end
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
def cleanup
|
127
127
|
handler = trap("INT") do
|
128
128
|
trap("INT", handler)
|
@@ -146,7 +146,7 @@ class EasyServe
|
|
146
146
|
log.debug {"client pid=#{pid} was already waited for"}
|
147
147
|
end
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
if @owner
|
151
151
|
services.each do |name, service|
|
152
152
|
log.info "stopping #{name}"
|
@@ -161,10 +161,10 @@ class EasyServe
|
|
161
161
|
end
|
162
162
|
end
|
163
163
|
end
|
164
|
-
|
164
|
+
|
165
165
|
clean_tmpdir
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
def start_services
|
169
169
|
return unless @owner
|
170
170
|
|
@@ -174,7 +174,7 @@ class EasyServe
|
|
174
174
|
return
|
175
175
|
end
|
176
176
|
|
177
|
-
lock_success = with_lock_file
|
177
|
+
lock_success = with_lock_file(*File.split(services_file)) do
|
178
178
|
# Successful creation of the lock file gives this process the
|
179
179
|
# right to check and create the services_file itself.
|
180
180
|
|
@@ -225,11 +225,11 @@ class EasyServe
|
|
225
225
|
Dir.mktmpdir "easy-serve-"
|
226
226
|
end
|
227
227
|
end
|
228
|
-
|
228
|
+
|
229
229
|
def clean_tmpdir
|
230
230
|
FileUtils.remove_entry @tmpdir if @tmpdir
|
231
231
|
end
|
232
|
-
|
232
|
+
|
233
233
|
def choose_socket_filename name, base: nil
|
234
234
|
if base
|
235
235
|
"#{base}-#{name}"
|
@@ -241,7 +241,7 @@ class EasyServe
|
|
241
241
|
def self.bump_socket_filename name
|
242
242
|
name =~ /-\d+\z/ ? name.succ : name + "-0"
|
243
243
|
end
|
244
|
-
|
244
|
+
|
245
245
|
def host_name
|
246
246
|
EasyServe.host_name
|
247
247
|
end
|
@@ -265,7 +265,7 @@ class EasyServe
|
|
265
265
|
def EasyServe.ssh_supports_dynamic_ports_forwards
|
266
266
|
@ssh_6 ||= (Integer(`ssh -V 2>&1`[/OpenSSH_(\d)/i, 1]) >= 6 rescue false)
|
267
267
|
end
|
268
|
-
|
268
|
+
|
269
269
|
MAX_TRIES = 10
|
270
270
|
|
271
271
|
# Start a service named +name+. The name is referenced in #child, #local,
|
@@ -316,11 +316,11 @@ class EasyServe
|
|
316
316
|
|
317
317
|
service = Service.for(name, proto, **opts)
|
318
318
|
rd, wr = IO.pipe
|
319
|
-
|
319
|
+
fork do
|
320
320
|
rd.close
|
321
321
|
log.progname = name
|
322
322
|
log.info "starting"
|
323
|
-
|
323
|
+
|
324
324
|
svr = service.serve(max_tries: MAX_TRIES, log: log)
|
325
325
|
yield svr if block_given?
|
326
326
|
no_interrupt_if_interactive
|
@@ -345,7 +345,7 @@ class EasyServe
|
|
345
345
|
(passive ? passive_children : children) << c
|
346
346
|
c
|
347
347
|
end
|
348
|
-
|
348
|
+
|
349
349
|
# A local client runs in the same process, not a child process.
|
350
350
|
def local *service_names
|
351
351
|
conns = service_names.map {|sn| services[sn].connect}
|
@@ -356,7 +356,7 @@ class EasyServe
|
|
356
356
|
end
|
357
357
|
log.info "stopped local client"
|
358
358
|
end
|
359
|
-
|
359
|
+
|
360
360
|
# ^C in the irb session (parent process) should not kill the
|
361
361
|
# service (child process)
|
362
362
|
def no_interrupt_if_interactive
|
@@ -23,12 +23,12 @@ class EasyServe
|
|
23
23
|
require 'drb'
|
24
24
|
require 'yaml'
|
25
25
|
require 'easy-serve'
|
26
|
-
|
26
|
+
|
27
27
|
service_names = #{service_names.inspect}
|
28
28
|
services = YAML.load(#{YAML.dump(services).inspect})
|
29
29
|
log_level = #{log.level}
|
30
30
|
host_uri = #{host_uri.inspect}
|
31
|
-
|
31
|
+
|
32
32
|
EasyServe.start services: services do |ez|
|
33
33
|
log = ez.log
|
34
34
|
log.level = log_level
|
@@ -38,7 +38,7 @@ class EasyServe
|
|
38
38
|
begin
|
39
39
|
DRb.start_service(host_uri, {conns: conns})
|
40
40
|
puts DRb.uri
|
41
|
-
|
41
|
+
|
42
42
|
Thread.new do
|
43
43
|
loop do
|
44
44
|
sleep 1
|
@@ -49,7 +49,7 @@ class EasyServe
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
DRb.thread.join
|
54
54
|
|
55
55
|
rescue => ex
|
@@ -61,10 +61,10 @@ class EasyServe
|
|
61
61
|
puts "ez error", ex, ex.backtrace
|
62
62
|
end
|
63
63
|
}
|
64
|
-
|
64
|
+
|
65
65
|
ssh.close_write
|
66
66
|
result = ssh.gets
|
67
|
-
|
67
|
+
|
68
68
|
if !result
|
69
69
|
raise RemoteError, "problem with ssh connection to remote"
|
70
70
|
else
|
@@ -79,7 +79,7 @@ class EasyServe
|
|
79
79
|
ssh.gets # consume the "."
|
80
80
|
end
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
log.debug "remote is at #{uri}"
|
84
84
|
ro = DRbObject.new_with_uri(uri)
|
85
85
|
conns = ro[:conns]
|
@@ -12,7 +12,7 @@ def EasyServe.manage_remote_eval_client msg
|
|
12
12
|
services_list.each do |service|
|
13
13
|
services[service.name] = service
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
log_args = msg["log"]
|
17
17
|
log =
|
18
18
|
case log_args
|
@@ -29,7 +29,7 @@ def EasyServe.manage_remote_eval_client msg
|
|
29
29
|
log.level = log_level
|
30
30
|
log.formatter = nil if $VERBOSE
|
31
31
|
|
32
|
-
ez.local
|
32
|
+
ez.local(*service_names) do |*conns|
|
33
33
|
begin
|
34
34
|
pr = eval "proc do |conns, host, log| #{eval_string}; end"
|
35
35
|
pr[conns, host, log]
|
@@ -43,7 +43,7 @@ def EasyServe.manage_remote_eval_client msg
|
|
43
43
|
puts ex.backtrace
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
log.info "done"
|
48
48
|
end
|
49
49
|
rescue LoadError, ScriptError, StandardError => ex
|
@@ -15,7 +15,7 @@ def EasyServe.manage_remote_run_client msg
|
|
15
15
|
services_list.each do |service|
|
16
16
|
services[service.name] = service
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
### opt for tmpdir and send files to it via ssh
|
20
20
|
Dir.chdir(dir) if dir
|
21
21
|
load file
|
@@ -36,7 +36,7 @@ def EasyServe.manage_remote_run_client msg
|
|
36
36
|
log.level = log_level
|
37
37
|
log.formatter = nil if $VERBOSE
|
38
38
|
|
39
|
-
ez.local
|
39
|
+
ez.local(*service_names) do |*conns|
|
40
40
|
begin
|
41
41
|
cl = Object.const_get(class_name)
|
42
42
|
ro = cl.new(conns, host, log, *args)
|
@@ -45,7 +45,7 @@ def EasyServe.manage_remote_run_client msg
|
|
45
45
|
puts "ez error", ex.inspect, ex.backtrace
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
log.info "done"
|
50
50
|
end
|
51
51
|
rescue LoadError, ScriptError, StandardError => ex
|
data/lib/easy-serve/service.rb
CHANGED
@@ -57,7 +57,7 @@ class EasyServe
|
|
57
57
|
SERVICE_CLASS[:unix] = self
|
58
58
|
|
59
59
|
attr_reader :path
|
60
|
-
|
60
|
+
|
61
61
|
def initialize name, path: nil
|
62
62
|
super name
|
63
63
|
@path = path
|
@@ -67,7 +67,7 @@ class EasyServe
|
|
67
67
|
super.tap do |svr|
|
68
68
|
found_path = svr.addr[1]
|
69
69
|
log.debug "#{inspect} is listening at #{found_path}"
|
70
|
-
|
70
|
+
|
71
71
|
if found_path != path
|
72
72
|
log.error "Unexpected path: #{found_path} != #{path}"
|
73
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy-serve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.14'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel VanderWerf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
101
|
+
rubygems_version: 2.4.1
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Framework for starting tcp/unix services and connected clients under one
|