Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add --chdir option to rackup

  • Loading branch information...
commit b5a47e25cf65ad2d87cf9e20474ca372ed91c1b0 1 parent 43de603
@josh josh authored
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/rack/server.rb
View
11 lib/rack/server.rb
@@ -48,6 +48,10 @@ def parse!(args)
options[:Port] = port
}
+ opts.on("-c", "--chdir DIR", "Change to dir before starting") { |dir|
+ options[:chdir] = ::File.expand_path(dir)
+ }
+
opts.on("-E", "--env ENVIRONMENT", "use ENVIRONMENT for defaults (default: development)") { |e|
options[:environment] = e
}
@@ -57,7 +61,7 @@ def parse!(args)
}
opts.on("-P", "--pid FILE", "file to store PID (default: rack.pid)") { |f|
- options[:pid] = ::File.expand_path(f)
+ options[:pid] = f
}
opts.separator ""
@@ -95,12 +99,13 @@ def options
def default_options
{
+ :chdir => Dir.pwd,
:environment => "development",
:pid => nil,
:Port => 9292,
:Host => "0.0.0.0",
:AccessLog => [],
- :config => ::File.expand_path("config.ru")
+ :config => "config.ru"
}
end
@@ -130,6 +135,8 @@ def middleware
end
def start
+ Dir.chdir(options[:chdir])
+
if options[:debug]
$DEBUG = true
require 'pp'

6 comments on commit b5a47e2

@sr

Why not just cd foo && rackup?

@josh

Yeah, that works too ;)

This is meant to emulate chdir support that is in thin, mongrel_rails, etc.

@josh

yeah know what, fuck it, reverting...

@lifo

This will be a nice option to have if rackup starts accepting yaml configuration file ala thin.

@josh

@lifo we need a unix tools that converts a yaml config into command line flags.

@josh

cargs - http://github.com/josh/cargs

it only took 2 hours :)

Please sign in to comment.
Something went wrong with that request. Please try again.