playframework 2.0 - Shuting down Akka system when in Play2 development mode -
i'm developing app akka , play2.
when run play2 app ~run
first time , make custom actor system created in controller , starts cluster on 2558 port.
if change in code , make play recompiles , start on suppose 2558 port taken , i've got error: failed bind /127.0.0.1:2558
.
i don't know how handle own actors systems shutdown work play2. i've tried in globalsettings
object in onstop
method no luck.
any advices?
use play.api.libs.concurrent.akka.system
actor system. can customise actor system want in application.conf
. play automatically starts , shuts down you.
if reason don't want use (but really, can't think of reason why ever not use it), need wait actor system shutdown in globalsettings.onstop
method, using actorsystem.awaittermination
. calling shutdown
non blocking, when play starts up, it's actorsystem
won't have shut down , released port yet.
also, don't create actor system in controller. either create in global
, or implement play.api.plugin
interface , create 1 there (the latter preferred has lifecycle).
Comments
Post a Comment