Running separate process

35 views
Skip to first unread message

Stefaan Delanghe

unread,
Feb 13, 2017, 8:10:44 AM2/13/17
to finatra-users
Hi,

I have a finatra http server defined. Aside from my endpoints i need a running process that runs in the background that consumes messages from a queue.

How can i incorporate a seperate process on startup?

I have setup a com.twitter.inject.app.app but this is not executable.

Thanks

Christopher Coco

unread,
Feb 13, 2017, 10:59:39 AM2/13/17
to Stefaan Delanghe, finatra-users
If you mean you want to run something along-side your server in a separate process and are just asking how you start a c.t.inject.app.App -- c.t.inject.app.App extends from c.t.app.App and thus has a main method so is executable (Finatra manages the lifecycle, thus you don't have access to put code in the main instead your code would go in App#run -- but it still has a main method). We don't have any direct examples of how you start an app as it would be exactly like a server (since TwitterServer itself is a c.t.app.App). Similar to servers (if you are writing this in scala) your app should have an object that extends the app's class. The you either run it's jar or run the main object passing any necessary flags. We have a roadmap item to add a simple app example so please stay tuned.

If your question is how you start a separate thread from inside your running http server -- that is a different question. You would define a module and start your long-lived other "process" in the singletonStartup method of the Module and likewise clean it up in the singletonShutdown method of the Module. Then just include this module in your server's list of modules. You would not define a c.t.inject.app.App for this case.

Thanks,
-c

--
You received this message because you are subscribed to the Google Groups "finatra-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to finatra-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stefaan Delanghe

unread,
Feb 13, 2017, 6:07:47 PM2/13/17
to finatra-users
thanks this explanation has been very helpfull!
Reply all
Reply to author
Forward
0 new messages