Permalink
Browse files

Add bind option

  • Loading branch information...
1 parent 1be724c commit 0acfae877d1c4fce81e7d76beba9597dce0556bc @gdb gdb committed Sep 27, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 bin/einhorn
View
@@ -185,6 +185,17 @@ if true # $0 == __FILE__
Einhorn::TransientState.environ = ENV.to_hash
optparse = OptionParser.new do |opts|
+ opts.on('-b ADDR', '--bind ADDR', 'Bind an address and add the corresponding FD to EINHORN_FDS') do |addr|
+ unless addr =~ /\A([^:]+):(\d+)((?:,\w+)*)\Z/
+ raise "Invalid value for #{addr.inspect}: bind address must be of the form address:port[,flags...]"
+ end
+
+ host = $1
+ port = Integer($2)
+ flags = $3.split(',').select {|flag| flag.length > 0}.map {|flag| flag.downcase}
+ Einhorn::State.bind << [host, port, flags]
+ end
+
opts.on('-c CMD_NAME', '--command-name CMD_NAME', 'Set the command name in ps to this value') do |cmd_name|
Einhorn::State.cmd_name = cmd_name
end

0 comments on commit 0acfae8

Please sign in to comment.