change config file for a custom server
flop opened this issue · 2 comments
flop commented
I'm trying to set a new default config file for a custom server.
For now, I have an ugly workaround where I add the config file to the arguments array :
require File.expand_path('../application', __FILE__)
require 'goliath/runner'
ARGV << '--config' << './config/config.rb'
runner = Goliath::Runner.new(ARGV, Application.new)
runner.log_file = './log/goliath.log'
runner.pid_file = './pid/goliath.pid'
runner.app = Goliath::Rack::Builder.build(Application, runner.api)
runner.run
I can't find a way to do it using the same way as for the log_file. Something like runner.config = './config/config.rb'
maxlinc commented
I'm not sure about using it with Goliath::Rack::Builder, but this works for me with a Goliath::API:
In your executable:
require 'goliath/api'
require 'goliath/runner'
require 'custom_api'
runner = Goliath::Runner.new(ARGV, CustomAPI.new)
runner.run
In custom_api.rb:
class CustomAPI < Goliath::API
# Your API code...
def options_parser(opts, options)
options[:config] ||= File.expand_path('../config.rb', __FILE__)
end
end
maxlinc commented
Seems like you still do need the app. I guess the main change is not passing nil as the second argument to Goliath::Runner.new
.
require 'goliath/api'
require 'goliath/runner'
require 'custom_api'
runner = Goliath::Runner.new(ARGV, CustomAPI.new)
runner.app = Goliath::Rack::Builder.build(CustomAPI, runner.api)
runner.run