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

What's the purpose of Goliath.run_app_on_exit = true ? #320

Open
devmod opened this issue Oct 19, 2015 · 3 comments
Open

What's the purpose of Goliath.run_app_on_exit = true ? #320

devmod opened this issue Oct 19, 2015 · 3 comments

Comments

@devmod
Copy link

devmod commented Oct 19, 2015

So, I had accidentally put a typo into

  def on_close(env) 

on my Goliath::API class and noticed the app would (after crashing) remain running but on a different port (9000).
I tested locally and noticed that it does not happen if we use the --daemonize flag.
(We don't use --daemonize flag bc of how we have upstart configured.)

So, long story short I realized that what was happening was that the app was being restarted with the default configuration by this flag:

   Goliath.run_app_on_exit

So, I am wondering.. what is the purpose of this flag? and why is it true by default?

Cheers

@igrigorik
Copy link
Member

It's the default behavior for Goliath:

. The motivation is similar to why minitest and others use the same pattern (see here). You can override this behavior though.. see our spec runner code.

@devmod
Copy link
Author

devmod commented Oct 20, 2015

Thanks for the explanation, I based myself on the custom server example https://github.com/postrank-labs/goliath/blob/master/examples/custom_server.rb

So, I have the following right now:

runner = Goliath::Runner.new(ARGV, nil)
runner.api = ApiServer.new
runner.logger = custom_logger
runner.app = Goliath::Rack::Builder.build(ApiServer, runner.api)
runner.run

But if I comment runner.run, the app starts anyway because of the on_exit hook, so I am now wondering if the runner.run is required in here? Having it there is what's causing my "starts a new instance when exiting/halting" issue.
(starting it manually like so: ruby my_api.rb --e dev )

@igrigorik
Copy link
Member

You can disable the on_exit logic via:

# Controls whether or not the application will be run using an at_exit block.

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