Skip to content

Commit

Permalink
Change from EINHORN_FD -> EINHORN_SOCK_FD
Browse files Browse the repository at this point in the history
  • Loading branch information
gdb committed Sep 27, 2012
1 parent f1f5d06 commit 1295b40
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bin/einhorn
Expand Up @@ -122,7 +122,7 @@ to the UNIX socket pointed to by the environment variable
To make things even easier, you can pass a `-b` to Einhorn, in which
case you just need to `write()` the above message to the open file
descriptor pointed to by `EINHORN_FD`.
descriptor pointed to by `EINHORN_SOCK_FD`.
(See `lib/einhorn/worker.rb` for details of these and other socket
discovery mechanisms.)
Expand Down Expand Up @@ -174,7 +174,7 @@ if true # $0 == __FILE__
Einhorn::TransientState.environ = ENV.to_hash

optparse = OptionParser.new do |opts|
opts.on('-b', '--command-socket-as-fd', 'Leave the command socket open as a file descriptor, passed in the EINHORN_FD environment variable. This allows your worker processes to ACK without needing to know where on the filesystem the command socket lives.') do
opts.on('-b', '--command-socket-as-fd', 'Leave the command socket open as a file descriptor, passed in the EINHORN_SOCK_FD environment variable. This allows your worker processes to ACK without needing to know where on the filesystem the command socket lives.') do
Einhorn::State.command_socket_as_fd = true
end

Expand Down
8 changes: 4 additions & 4 deletions lib/einhorn/command.rb
Expand Up @@ -189,7 +189,7 @@ def self.spinup(cmd=nil)
Einhorn::Event.close_all_for_worker
Einhorn.set_argv(cmd, true)

pass_command_socket_info
prepare_child_environment
einhorn_main
end
else
Expand All @@ -203,7 +203,7 @@ def self.spinup(cmd=nil)
# cloexec on everything.
Einhorn::Event.close_all_for_worker

pass_command_socket_info
prepare_child_environment
exec [cmd[0], cmd[0]], *cmd[1..-1]
end
end
Expand All @@ -228,14 +228,14 @@ def self.spinup(cmd=nil)
end
end

def self.pass_command_socket_info
def self.prepare_child_environment
# This is run from the child
ENV['EINHORN_MASTER_PID'] = Process.ppid.to_s
ENV['EINHORN_SOCK_PATH'] = Einhorn::Command::Interface.socket_path
if Einhorn::State.command_socket_as_fd
socket = UNIXSocket.open(Einhorn::Command::Interface.socket_path)
Einhorn::TransientState.socket_handles << socket
ENV['EINHORN_FD'] = socket.fileno.to_s
ENV['EINHORN_SOCK_FD'] = socket.fileno.to_s
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/einhorn/worker.rb
Expand Up @@ -38,7 +38,7 @@ def self.ack(*args)
#
# @discovery: How to discover the master process's command socket.
# :env: Discover the path from ENV['EINHORN_SOCK_PATH']
# :fd: Just use the file descriptor in ENV['EINHORN_FD'].
# :fd: Just use the file descriptor in ENV['EINHORN_SOCK_FD'].
# Must run the master with the -b flag. This is mostly
# useful if you don't have a nice library like Einhorn::Worker.
# Then @arg being true causes the FD to be left open after ACK;
Expand All @@ -57,7 +57,7 @@ def self.ack!(discovery=:env, arg=nil)
socket = ENV['EINHORN_SOCK_PATH']
client = Einhorn::Client.for_path(socket)
when :fd
raise "No EINHORN_FD provided in environment. Did you run einhorn with the -b flag?" unless fd_str = ENV['EINHORN_FD']
raise "No EINHORN_SOCK_FD provided in environment. Did you run einhorn with the -b flag?" unless fd_str = ENV['EINHORN_SOCK_FD']

fd = Integer(fd_str)
client = Einhorn::Client.for_fd(fd)
Expand Down

0 comments on commit 1295b40

Please sign in to comment.