Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change config file for a custom server #257

Open
flop opened this issue Aug 19, 2013 · 2 comments
Open

change config file for a custom server #257

flop opened this issue Aug 19, 2013 · 2 comments

Comments

@flop
Copy link

flop commented Aug 19, 2013

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
Copy link

maxlinc commented Jan 20, 2014

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
Copy link

maxlinc commented Jan 20, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants