|
|
|
@ -39,16 +39,14 @@ $stderr.puts "serving control socket"
|
|
|
|
|
|
|
|
|
|
connection_id = 0 |
|
|
|
|
|
|
|
|
|
def open_pipe(connection_id, name) |
|
|
|
|
pipe_path = "/tmp/github-fast-envd.#{connection_id}.#{name}" |
|
|
|
|
|
|
|
|
|
if File.exist?(pipe_path) and File.pipe?(pipe_path) |
|
|
|
|
File.unlink(pipe_path) |
|
|
|
|
def open_pipe(path) |
|
|
|
|
if File.exist?(path) and File.pipe?(path) |
|
|
|
|
File.unlink(path) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
File.mkfifo(pipe_path, mode = 0600) |
|
|
|
|
File.mkfifo(path, mode = 0600) |
|
|
|
|
|
|
|
|
|
pipe_path |
|
|
|
|
path |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def read_command(control_socket) |
|
|
|
@ -86,18 +84,19 @@ def read_command(control_socket)
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def set_up_named_pipes(control_socket, connection_id) |
|
|
|
|
stdin = open_pipe(connection_id, "stdin") |
|
|
|
|
control_socket.puts "stdin #{stdin}" |
|
|
|
|
pipe_base_path = "/tmp/github-fast-envd.#{connection_id}" |
|
|
|
|
pipe_base_path_encoded = Base64.encode64(pipe_base_path).delete("\n") |
|
|
|
|
|
|
|
|
|
stdin = open_pipe("#{pipe_base_path}.stdin") |
|
|
|
|
stdout = open_pipe("#{pipe_base_path}.stdout") |
|
|
|
|
stderr = open_pipe("#{pipe_base_path}.stderr") |
|
|
|
|
|
|
|
|
|
control_socket.puts "named-pipes #{pipe_base_path_encoded}" |
|
|
|
|
|
|
|
|
|
stdin = File::open(stdin, "r") |
|
|
|
|
stdin.sync = true |
|
|
|
|
|
|
|
|
|
stdout = open_pipe(connection_id, "stdout") |
|
|
|
|
control_socket.puts "stdout #{stdout}" |
|
|
|
|
stdout = File::open(stdout, "w") |
|
|
|
|
stdout.sync = true |
|
|
|
|
|
|
|
|
|
stderr = open_pipe(connection_id, "stderr") |
|
|
|
|
control_socket.puts "stderr #{stderr}" |
|
|
|
|
stderr = File::open(stderr, "w") |
|
|
|
|
stderr.sync = true |
|
|
|
|
|
|
|
|
|