Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
allow specifing config file on the command line
  • Loading branch information
dj2 committed Mar 21, 2011
1 parent e97d2dd commit 5c0738a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/goliath/runner.rb
Expand Up @@ -106,6 +106,7 @@ def options_parser
opts.on('-l', '--log FILE', "Log to file (default: off)") { |file| @options[:log_file] = file }
opts.on('-s', '--stdout', "Log to stdout (default: #{@options[:log_stdout]})") { |v| @options[:log_stdout] = v }

opts.on('-c', '--config FILE', "Config file (default: ./config/<server>.rb)") { |v| @options[:config] = v }
opts.on('-P', '--pid FILE', "Pid file (default: off)") { |file| @options[:pid_file] = file }
opts.on('-d', '--daemonize', "Run daemonized in the background (default: #{@options[:daemonize]})") { |v| @options[:daemonize] = v }
opts.on('-v', '--verbose', "Enable verbose logging (default: #{@options[:verbose]})") { |v| @options[:verbose] = v }
Expand Down
9 changes: 3 additions & 6 deletions lib/goliath/server.rb
Expand Up @@ -75,7 +75,7 @@ def start

EM.epoll

load_config
load_config(options[:config])
load_plugins

EM.set_effective_user(options[:user]) if options[:user]
Expand Down Expand Up @@ -109,11 +109,8 @@ def load_config(file = nil)
#
# @return [String] THe full path to the config directory
def config_dir
if Goliath.test?
"#{File.expand_path(ENV['PWD'])}/config"
else
File.expand_path('./config')
end
dir = options[:config] ? File.dirname(options[:config]) : './config'
File.expand_path(dir)
end

# Import callback for configuration files
Expand Down

0 comments on commit 5c0738a

Please sign in to comment.