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

Startup / Shutdown hooks #37

Closed
LeifWarner opened this issue Mar 6, 2013 · 2 comments

Comments

@LeifWarner
Copy link

commented Mar 6, 2013

E.g. initialize / shutdown a redis connection pool. I didn't see a place to put these. Many require a call for the threadpool to be shutdown for the app to exit cleanly.

I suppose one could put stuff on a singleton object, that the controller could access, and have the thing that starts up FinatraServer manage starting up and shutting down the stuff that lives there?

@capotej

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2013

So FinatraServer.start() is usually called from a main method in your App object, you could just initialize the redis threadpool in that main method, and attach it to val on the App object, making it available throughout your whole app. As for shutdown, you could register a jvm shutdown hook to cleanly shutdown the redis threadpool if you wish, like so:

Runtime.getRuntime.addShutdownHook(
    new Thread(new Runnable() {
      override def run() { App.shutdown() }
    }))

Does this answer your question?

@capotej

This comment has been minimized.

Copy link
Contributor

commented Jun 14, 2013

Closing, please reopen if you need more assistance.

@capotej capotej closed this Jun 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.