-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JRuby support: UNIXSocket#recv_io/send_io workaround, pooled applicat…
…ion manager (instead of fork) - only used if fork if not supported
- Loading branch information
Showing
20 changed files
with
593 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
require "spring/process_title_updater" | ||
require "spring/json" | ||
require "spring/watcher" | ||
require "spring/io_helpers" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "spring/platform" | ||
|
||
if Spring.fork? | ||
require "spring/impl/fork/application" | ||
else | ||
require "spring/impl/pool/application" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "spring/platform" | ||
|
||
if Spring.fork? | ||
require "spring/impl/fork/application_manager" | ||
else | ||
require "spring/impl/pool/application_manager" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
module Spring | ||
module ApplicationImpl | ||
def notify_manager_ready | ||
manager.puts | ||
end | ||
|
||
def receive_streams(client) | ||
3.times.map { IOWrapper.recv_io(client).to_io } | ||
end | ||
|
||
def reopen_streams(streams) | ||
[STDOUT, STDERR, STDIN].zip(streams).each { |a, b| a.reopen(b) } | ||
end | ||
|
||
def eager_preload | ||
with_pty { preload } | ||
end | ||
|
||
def with_pty | ||
PTY.open do |master, slave| | ||
[STDOUT, STDERR, STDIN].each { |s| s.reopen slave } | ||
Thread.new { master.read } | ||
yield | ||
reset_streams | ||
end | ||
end | ||
|
||
def reset_streams | ||
[STDOUT, STDERR].each { |stream| stream.reopen(spring_env.log_file) } | ||
STDIN.reopen("/dev/null") | ||
end | ||
|
||
def wait(pid, streams, client) | ||
@mutex.synchronize { @waiting << pid } | ||
|
||
# Wait in a separate thread so we can run multiple commands at once | ||
Thread.new { | ||
begin | ||
_, status = Process.wait2 pid | ||
log "#{pid} exited with #{status.exitstatus}" | ||
|
||
streams.each(&:close) | ||
client.puts(status.exitstatus) | ||
client.close | ||
ensure | ||
@mutex.synchronize { @waiting.delete pid } | ||
exit_if_finished | ||
end | ||
} | ||
end | ||
|
||
def fork_child(client, streams, child_started) | ||
pid = fork { yield } | ||
child_started[0] = true | ||
|
||
disconnect_database | ||
reset_streams | ||
|
||
log "forked #{pid}" | ||
manager.puts pid | ||
|
||
wait pid, streams, client | ||
end | ||
|
||
def before_command | ||
# NOP | ||
end | ||
end | ||
end |
File renamed without changes.
Oops, something went wrong.