We built multiple microservices based on Lagom which are independently deployable, on our cloud setup we deploy like that, but on some onpremise setup it become and issue to run multiple Lagom Services in diff. process.
We were able to run multiple Lagom Based Applications in a Single Process by hacking into the Play class which stops one application if another is started by hacking into the Play scala:
val globalApp = app.globalApplicationEnabled
if (globalApp && _currentApp != null && _currentApp.globalApplicationEnabled) {
logger.info("Stopping current application")
stop(_currentApp)
}
I updated this to:
val globalApp = app.globalApplicationEnabled
if (globalApp && _currentApp != null && _currentApp.globalApplicationEnabled) {
logger.info("Stopping current application")
}
My question: is this right to do, what possible impact in lagom applications or any other way to up multiple services in a Single Process
You shouldn't need that hack, you should be able to just add this to each of your applications application.conf
:
play.allowGlobalApplication = false
This will turn Play's global application support off, which will mean in the above if condition, globalApp
will be false and so it won't stop the current application when you start a second application.
If you have any problems doing this, eg if you get exceptions saying that something is trying to access the global application, then you've likely found a bug in Lagom and/or Play, which you can report to their issue trackers.
The consequences of running multiple Lagom's in one process are:
There's probably some other things to be aware of, but I can't think of them right now.