Create socket and pipes in /run

This commit is contained in:
Patrick Lühne 2020-05-26 03:51:05 +02:00
parent e1b0d7b0eb
commit 64278b6573
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
2 changed files with 9 additions and 3 deletions

View File

@ -33,7 +33,7 @@ end
# TODO: support arguments # TODO: support arguments
script_path = File.realpath(ARGV[0]) script_path = File.realpath(ARGV[0])
control_socket_path = "/tmp/github-fast-envd.sock" control_socket_path = "/run/github-fast-env/github-fast-envd.sock"
$original_stdin = $stdin.dup $original_stdin = $stdin.dup
$original_stdout = $stdout.dup $original_stdout = $stdout.dup

View File

@ -29,7 +29,13 @@ $original_stdin = $stdin.dup
$original_stdout = $stdout.dup $original_stdout = $stdout.dup
$original_stderr = $stderr.dup $original_stderr = $stderr.dup
control_socket_path = "/tmp/github-fast-envd.sock" $run_base_path = "/run/github-fast-env"
unless File.directory?($run_base_path)
FileUtils.mkdir_p($run_base_path, :mode => 0700)
end
control_socket_path = "#{$run_base_path}/github-fast-envd.sock"
if File.exist?(control_socket_path) and File.socket?(control_socket_path) if File.exist?(control_socket_path) and File.socket?(control_socket_path)
File.unlink(control_socket_path) File.unlink(control_socket_path)
@ -87,7 +93,7 @@ def read_command(control_socket)
end end
def set_up_named_pipes(control_socket, connection_id) def set_up_named_pipes(control_socket, connection_id)
pipe_base_path = "/tmp/github-fast-envd.#{connection_id}" pipe_base_path = "/#{$run_base_path}/github-fast-envd.#{connection_id}"
pipe_base_path_encoded = Base64.encode64(pipe_base_path).delete("\n") pipe_base_path_encoded = Base64.encode64(pipe_base_path).delete("\n")
stdin = open_pipe("#{pipe_base_path}.stdin") stdin = open_pipe("#{pipe_base_path}.stdin")