set up the API before running the server #221

Merged
merged 1 commit into from Jan 9, 2013

Conversation

Projects
None yet
2 participants
Contributor

marcoow commented Jan 8, 2013

Adds support to run setup tasks before the server actually starts and accepts connections. In our case that was starting up the NewRelic agent etc.

Note that while these setup scripts could be run in the app.rb file as well that could sometimes cause problems as when run in demonized mode, the server will run in a different process than the app.rb files itself which can sometimes cause problems (e.g. in the case of NewRelic it would start the NewRelic agent in the process that is exited when the server process is forked later).

Owner

igrigorik commented Jan 8, 2013

Hmm, interesting. Can you post a simple example of the setup method in use? Also, not sure if this was already there, but Travis doesn't seem to be happy - although don't see why your change would trigger that error, at least on the surface.

Contributor

marcoow commented Jan 8, 2013

The example in our case was simply

class Server < Goliath::Api
  def setup
    NewRelic::Agent.manual_start
  end
end

As NewRelic runs the agent in the same process the caller runs in I have to do that after the fork happened.

Contributor

marcoow commented Jan 8, 2013

Also the problem in Travis looks like the at_exit hook tries to run a non-existent API?

@igrigorik igrigorik added a commit that referenced this pull request Jan 9, 2013

@igrigorik igrigorik Merge pull request #221 from scoreloop/setup-api
set up the API before running the server
e832599

@igrigorik igrigorik merged commit e832599 into postrank-labs:master Jan 9, 2013

1 check failed

default The Travis build failed
Details
Owner

igrigorik commented Jan 9, 2013

Looks good - thanks! Will take a look at the failing spec separately, since that seems completely unrelated.

marcoow deleted the unknown repository branch Jan 9, 2013

marcoow restored the unknown repository branch Jan 9, 2013

marcoow deleted the unknown repository branch Jan 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment