File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
lib/ruby_lsp/ruby_lsp_rails Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ def initialize
31
31
# parent ends, the spring process ends as well. If this is not set, Spring will throw an error while trying to
32
32
# set its own session ID
33
33
begin
34
+ Process . setpgrp
34
35
Process . setsid
35
36
rescue Errno ::EPERM
36
37
# If we can't set the session ID, continue
@@ -52,6 +53,14 @@ def initialize
52
53
warn ( "Ruby LSP Rails booting server" )
53
54
read_response
54
55
warn ( "Finished booting Ruby LSP Rails server" )
56
+
57
+ unless ENV [ "RAILS_ENV" ] == "test"
58
+ at_exit do
59
+ warn ( "Ruby LSP Rails is force killing the server" )
60
+ sleep ( 0.5 ) # give the server a bit of time if we already issued a shutdown notification
61
+ Process . kill ( T . must ( Signal . list [ "TERM" ] ) , @wait_thread . pid ) if @wait_thread . alive?
62
+ end
63
+ end
55
64
rescue Errno ::EPIPE , IncompleteMessageError
56
65
raise InitializationError , @stderr . read
57
66
end
@@ -66,8 +75,9 @@ def model(name)
66
75
67
76
sig { void }
68
77
def shutdown
69
- send_notification ( "shutdown" )
70
- Thread . pass while @wait_thread . alive?
78
+ warn ( "Ruby LSP Rails shutting down server" )
79
+ send_message ( "shutdown" )
80
+ sleep ( 0.5 ) # give the server a bit of time to shutdown
71
81
[ @stdin , @stdout , @stderr ] . each ( &:close )
72
82
end
73
83
Original file line number Diff line number Diff line change @@ -8,13 +8,13 @@ module RubyLsp
8
8
module Rails
9
9
class RunnerClientTest < ActiveSupport ::TestCase
10
10
setup do
11
- capture_io do
11
+ capture_subprocess_io do
12
12
@client = T . let ( RunnerClient . new , RunnerClient )
13
13
end
14
14
end
15
15
16
16
teardown do
17
- @client . shutdown
17
+ capture_subprocess_io { @client . shutdown }
18
18
assert_predicate @client , :stopped?
19
19
end
20
20
You can’t perform that action at this time.
0 commit comments