Skip to content

Commit e80b16a

Browse files
committed
Don't check for pidfile when running commands
This will allow running commands against a Spring server which is not running directly on the same machine. Specifically I'm making this change to enable running a Spring server inside a Docker container, and then connecting to it from outside the container (i.e. on a host machine).
1 parent f6a5b08 commit e80b16a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/spring/client/run.rb

+13-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class Run < Command
88
FORWARDED_SIGNALS = %w(INT QUIT USR1 USR2 INFO WINCH) & Signal.list.keys
99
TIMEOUT = 1
1010

11+
attr_reader :server
12+
1113
def initialize(args)
1214
super
1315
@signal_queue = []
@@ -17,20 +19,20 @@ def log(message)
1719
env.log "[client] #{message}"
1820
end
1921

20-
def server
21-
@server ||= UNIXSocket.open(env.socket_name)
22+
def connect
23+
@server = UNIXSocket.open(env.socket_name)
2224
end
2325

2426
def call
25-
if env.server_running?
26-
warm_run
27-
else
27+
begin
28+
connect
29+
rescue Errno::ENOENT, Errno::ECONNRESET
2830
cold_run
31+
else
32+
warm_run
2933
end
30-
rescue Errno::ECONNRESET
31-
exit 1
3234
ensure
33-
server.close if @server
35+
server.close if server
3436
end
3537

3638
def warm_run
@@ -49,6 +51,7 @@ def warm_run
4951

5052
def cold_run
5153
boot_server
54+
connect
5255
run
5356
end
5457

@@ -60,6 +63,8 @@ def run
6063
queue_signals
6164
connect_to_application(client)
6265
run_command(client, application)
66+
rescue Errno::ECONNRESET
67+
exit 1
6368
end
6469

6570
def boot_server

0 commit comments

Comments
 (0)