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

Add 2 methods in FinatraServer.scala for custom start() stop() Code #107

Closed
schmitch opened this issue Feb 3, 2014 · 6 comments

Comments

@schmitch
Copy link
Contributor

commented Feb 3, 2014

It would be great, to have two methods, where you could specify Custom start(), stop() code, that runs on the finatraserver startup / stop.
Currently I would need to override either start() / stop() and fill it with my own code.
This is not great, since I always need to take a look at the Finatra source code if something changes between the versions.

@stuhood

This comment has been minimized.

Copy link
Member

commented Feb 3, 2014

These are already provided by com.twitter.util.App, which FinatraServer extends.

See premain/postmain/onExit in App: https://github.com/twitter/util/blob/master/util-app/src/main/scala/com/twitter/app/App.scala#L41

@stuhood stuhood closed this Feb 3, 2014

@stuhood

This comment has been minimized.

Copy link
Member

commented Feb 3, 2014

(but please reopen if that's not what you meant!)

@schmitch

This comment has been minimized.

Copy link
Contributor Author

commented Feb 3, 2014

Nah it's fine.
I just could make a trait StartUp which inerhits App and defines a premain { } onExit { } postmain { } where i could define startup code.
Like this: https://github.com/twitter/finatra/blob/master/src/main/scala/com/twitter/finatra/AdminHttpServer.scala
Still thanks, that should be documented.

@capotej

This comment has been minimized.

Copy link
Contributor

commented Feb 3, 2014

I'll add those docs now; Been meaning to document premain/postmain as it seems to trip a lot of people up.

@stuhood

This comment has been minimized.

Copy link
Member

commented Feb 3, 2014

You don't need to create a new trait: as I said, FinatraServer already extends App.

All you need to do is call premain/postmain/onExit with a closure that should run. See the TwitterServer docs for an example of onExit: http://twitter.github.io/twitter-server/

@schmitch

This comment has been minimized.

Copy link
Contributor Author

commented Feb 3, 2014

Oh yeah thanks, sorry.
It's just too late here, to think clearly.

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