expedite 0.2.2 → 0.2.3
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/lib/expedite/client/agent_proxy.rb +27 -0
- data/lib/expedite/client/base.rb +6 -4
- data/lib/expedite/env.rb +26 -8
- data/lib/expedite/errors.rb +6 -0
- data/lib/expedite/protocol.rb +21 -0
- data/lib/expedite/server/agent.rb +2 -2
- data/lib/expedite/server/controller.rb +4 -1
- data/lib/expedite/version.rb +1 -1
- data/lib/expedite.rb +6 -25
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8babab9c1e4ea0a7e6b07fe21738b029200d6f32cf1630552bce7fef3a7f6092
|
|
4
|
+
data.tar.gz: c24fd8f9e9cd7720c32d37329c67cccb089987b8a24df30bfedb45cdb20f48e8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8beb17a4d477869134b0775b8437e15f51dbb9e51138b49355ea5fade24e7a771b07fdfec98f92c5bb28bf0cc876fa673befd3bd38848ca8c74fcda143996bd9
|
|
7
|
+
data.tar.gz: 3d810666ae634dfc032c99ee2b73d55f17790b552c85ab6dd4ba1e486c19374ac6e1d36fb0ff73badb1d5a807a5a1f1520ca7060dcda9e72ee2d306efed6cec1
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'expedite/client/exec'
|
|
2
|
+
require 'expedite/client/invoke'
|
|
3
|
+
|
|
4
|
+
module Expedite
|
|
5
|
+
module Client
|
|
6
|
+
class AgentProxy
|
|
7
|
+
attr_accessor :env, :agent
|
|
8
|
+
|
|
9
|
+
##
|
|
10
|
+
#
|
|
11
|
+
# @param env [Expedite::Env] Environment
|
|
12
|
+
# @param agent [String] Name of the agent
|
|
13
|
+
def initialize(env:, agent:)
|
|
14
|
+
self.env = env
|
|
15
|
+
self.agent = agent
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def exec(*args)
|
|
19
|
+
Client::Exec.new(env: env, agent: agent).call(*args)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def invoke(*args)
|
|
23
|
+
Client::Invoke.new(env: env, agent: agent).call(*args)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/expedite/client/base.rb
CHANGED
|
@@ -106,7 +106,9 @@ module Expedite
|
|
|
106
106
|
def boot_server
|
|
107
107
|
env.socket_path.unlink if env.socket_path.exist?
|
|
108
108
|
|
|
109
|
-
pid
|
|
109
|
+
pid = Bundler.with_original_env do
|
|
110
|
+
Process.spawn(gem_env, env.server_command, out: File::NULL, chdir: env.root)
|
|
111
|
+
end
|
|
110
112
|
timeout = Time.now + BOOT_TIMEOUT
|
|
111
113
|
|
|
112
114
|
@server_booted = true
|
|
@@ -118,9 +120,9 @@ module Expedite
|
|
|
118
120
|
# Server did not start
|
|
119
121
|
raise ArgumentError, "Server exited: #{status.exitstatus}"
|
|
120
122
|
elsif Time.now > timeout
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
exit 1
|
|
123
|
+
raise "Starting Expedite server with `#{env.server_command}` " \
|
|
124
|
+
"timed out after #{BOOT_TIMEOUT} seconds. Was waiting for #{env.socket_path} to appear."
|
|
125
|
+
#exit 1
|
|
124
126
|
end
|
|
125
127
|
|
|
126
128
|
sleep 0.1
|
data/lib/expedite/env.rb
CHANGED
|
@@ -6,19 +6,31 @@ require 'expedite/server/application_manager'
|
|
|
6
6
|
module Expedite
|
|
7
7
|
class Env
|
|
8
8
|
attr_accessor :root
|
|
9
|
-
attr_accessor :application_id, :app_name, :log_file
|
|
9
|
+
attr_accessor :application_id, :app_name, :log_file, :bundler
|
|
10
10
|
attr_reader :applications
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
##
|
|
13
|
+
# The environment containing the target application.
|
|
14
|
+
#
|
|
15
|
+
# The root and app_name are used to derive the socket.
|
|
16
|
+
# @param root [String] Path to the root directory.
|
|
17
|
+
# @param app_name [String] The name of the application.
|
|
18
|
+
# @param log_file [IO] Path to log file. If nil, logs are discarded.
|
|
19
|
+
# @param bundler [Boolean] If true, `bundle exec` will be added in front
|
|
20
|
+
# of the server command. Defaults to true.
|
|
21
|
+
def initialize(root: nil, app_name: nil, log_file: nil, bundler: true)
|
|
22
|
+
# Use realpath so that directories that are symlinked end up with
|
|
23
|
+
# the same root. This is important for getting the correct socket.
|
|
24
|
+
@root = File.realpath(root || Dir.pwd)
|
|
14
25
|
@app_name = app_name || File.basename(@root)
|
|
15
26
|
@log_file = log_file || File.open(File::NULL, "a")
|
|
16
|
-
@
|
|
27
|
+
@bundler = bundler
|
|
17
28
|
|
|
18
|
-
@application_id = Digest::SHA1.hexdigest(@root)
|
|
29
|
+
@application_id = Digest::SHA1.hexdigest(@root + "|" + @app_name)
|
|
30
|
+
@tmp_path = nil
|
|
19
31
|
|
|
20
|
-
|
|
21
|
-
@applications = Server::ApplicationManager.new(
|
|
32
|
+
# TODO: @applications should only be available in the server
|
|
33
|
+
@applications = Server::ApplicationManager.new(self)
|
|
22
34
|
end
|
|
23
35
|
|
|
24
36
|
def version
|
|
@@ -49,7 +61,13 @@ module Expedite
|
|
|
49
61
|
end
|
|
50
62
|
|
|
51
63
|
def server_command
|
|
52
|
-
|
|
64
|
+
bin_expedite = File.expand_path("../../../bin/expedite", __FILE__)
|
|
65
|
+
cmd = if bundler
|
|
66
|
+
"bundle exec #{bin_expedite}"
|
|
67
|
+
else
|
|
68
|
+
bin_expedite
|
|
69
|
+
end
|
|
70
|
+
"#{cmd} server --background"
|
|
53
71
|
end
|
|
54
72
|
|
|
55
73
|
def graceful_termination_timeout
|
data/lib/expedite/errors.rb
CHANGED
data/lib/expedite/protocol.rb
CHANGED
|
@@ -10,6 +10,25 @@ module Expedite
|
|
|
10
10
|
self.write data
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
##
|
|
14
|
+
# Result is an exception
|
|
15
|
+
#
|
|
16
|
+
def send_exception(e, env)
|
|
17
|
+
if !e.is_a?(Expedite::Error)
|
|
18
|
+
ie = Expedite::InvokeError.new("#{e.class}: #{e.message}")
|
|
19
|
+
ie.set_backtrace(e.backtrace)
|
|
20
|
+
e = ie
|
|
21
|
+
end
|
|
22
|
+
self.send_object({"exception" => e}, env)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
##
|
|
26
|
+
# Result is a normal return value
|
|
27
|
+
#
|
|
28
|
+
def send_return(obj, env)
|
|
29
|
+
self.send_object({"return" => obj}, env)
|
|
30
|
+
end
|
|
31
|
+
|
|
13
32
|
def recv_object
|
|
14
33
|
len = self.gets.to_i
|
|
15
34
|
data = self.read(len)
|
|
@@ -18,4 +37,6 @@ module Expedite
|
|
|
18
37
|
end
|
|
19
38
|
end
|
|
20
39
|
|
|
40
|
+
module ActiveRecord
|
|
41
|
+
end
|
|
21
42
|
IO.include ::Expedite::Protocol
|
|
@@ -223,9 +223,9 @@ module Expedite
|
|
|
223
223
|
begin
|
|
224
224
|
ret = action.call(*args)
|
|
225
225
|
rescue => e
|
|
226
|
-
client.
|
|
226
|
+
client.send_exception(e, self.env)
|
|
227
227
|
else
|
|
228
|
-
client.
|
|
228
|
+
client.send_return(ret, self.env)
|
|
229
229
|
end
|
|
230
230
|
end
|
|
231
231
|
end
|
|
@@ -7,6 +7,9 @@ require "expedite/signals"
|
|
|
7
7
|
|
|
8
8
|
module Expedite
|
|
9
9
|
module Server
|
|
10
|
+
##
|
|
11
|
+
# Controls the `expedite server`.
|
|
12
|
+
#
|
|
10
13
|
class Controller
|
|
11
14
|
include Signals
|
|
12
15
|
|
|
@@ -150,7 +153,7 @@ module Expedite
|
|
|
150
153
|
# boot only
|
|
151
154
|
#@child_socket = client.recv_io
|
|
152
155
|
#@log_file = client.recv_io
|
|
153
|
-
unix_socket.
|
|
156
|
+
unix_socket.send_exception(e, env)
|
|
154
157
|
|
|
155
158
|
unix_socket.close
|
|
156
159
|
client.close
|
data/lib/expedite/version.rb
CHANGED
data/lib/expedite.rb
CHANGED
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
require 'expedite/client/
|
|
2
|
-
require 'expedite/client/invoke'
|
|
1
|
+
require 'expedite/client/agent_proxy'
|
|
3
2
|
require 'expedite/syntax'
|
|
4
3
|
|
|
5
|
-
module Expedite
|
|
6
|
-
class AgentProxy
|
|
7
|
-
attr_accessor :env, :agent
|
|
8
|
-
|
|
9
|
-
def initialize(env:, agent:)
|
|
10
|
-
self.env = env
|
|
11
|
-
self.agent = agent
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def exec(*args)
|
|
15
|
-
Client::Exec.new(env: env, agent: agent).call(*args)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def invoke(*args)
|
|
19
|
-
Client::Invoke.new(env: env, agent: agent).call(*args)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
4
|
|
|
24
5
|
module Expedite
|
|
25
6
|
##
|
|
26
7
|
# Returns a client to dispatch actions to the specified agent
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
8
|
+
# @param name [String] Name of the agent that we want to talk to
|
|
9
|
+
# @param env [Expedite::Env] Defaults to an environment pointing to the
|
|
10
|
+
# current directory
|
|
11
|
+
def self.agent(name, env: Env.new)
|
|
12
|
+
Client::AgentProxy.new(env: env, agent: name)
|
|
32
13
|
end
|
|
33
14
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: expedite
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bing-Chang Lai
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-12-
|
|
11
|
+
date: 2022-12-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Manages Ruby processes that can be used to spawn child processes faster.
|
|
14
14
|
email: johnny.lai@me.com
|
|
@@ -29,6 +29,7 @@ files:
|
|
|
29
29
|
- lib/expedite/cli/server.rb
|
|
30
30
|
- lib/expedite/cli/status.rb
|
|
31
31
|
- lib/expedite/cli/stop.rb
|
|
32
|
+
- lib/expedite/client/agent_proxy.rb
|
|
32
33
|
- lib/expedite/client/base.rb
|
|
33
34
|
- lib/expedite/client/exec.rb
|
|
34
35
|
- lib/expedite/client/invoke.rb
|
|
@@ -65,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
65
66
|
- !ruby/object:Gem::Version
|
|
66
67
|
version: '0'
|
|
67
68
|
requirements: []
|
|
68
|
-
rubygems_version: 3.
|
|
69
|
+
rubygems_version: 3.4.1
|
|
69
70
|
signing_key:
|
|
70
71
|
specification_version: 4
|
|
71
72
|
summary: Expedite startup of Ruby process
|