Skip to content

Commit

Permalink
add bind/port options to start server command
Browse files Browse the repository at this point in the history
  • Loading branch information
machu committed May 9, 2013
1 parent 8ca0a98 commit f9603fd
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tdiary/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ def test
"start server with rack interface (default)"
method_option "cgi", :type => :string, :banner =>
"start server with cgi interface"
method_option "bind", :aliases => "b", :type => :string, :default => "0.0.0.0", :banner =>
"bind to the IP"
method_option "port", :aliases => "p", :type => :numeric, :default => 19292, :banner =>
"use PORT"
def server
if options[:cgi]
opts = {
:daemon => ENV['DAEMON'],
:bind => ENV['BIND'] || '0.0.0.0',
:port => ENV['PORT'] || 19292,
:bind => options[:bind],
:port => options[:port],
:logger => $stderr,
:access_log => $stderr,
}
Expand All @@ -62,7 +66,16 @@ def server
require 'rack'
# Rack::Server reads ARGV as :config, so delete it
ARGV.shift
Rack::Server.start
opts = {
:environment => ENV['RACK_ENV'] || "development",
:daemonize => false,
:Host => options[:bind],
:Port => options[:port],
:pid => File.expand_path("tdiary.pid"),
:AccessLog => $stderr,
:config => File.expand_path("config.ru")
}
Rack::Server.start( opts )
end
end

Expand Down

0 comments on commit f9603fd

Please sign in to comment.