Spray.IO Stop http server with Http.Unbind -


i have app built on spray 1.3.3 , i'm trying stop http server sending message. official documentation says:

stopping. explicitly stop server, send http.unbind command httplistener instance (the actorref instance available sender of http.bound confirmation event when server started).

here how start server:

(io(http) ? http.bind(httplistener, interface = iface, port = port)).map { case m: http.bound => println(s"success $iface:$port") case fail : http.commandfailed => println(s"bad try :(") } 

i tried send message http.unbind httplistener no success. seems it's not actor

may need extract somehow sender ref of http.bound message? how?

here httplistener's head:

class myhttplistener extends httpserviceactor {    import context.dispatcher    def receive = runroute(      path("shutdown") {        {          actors.httplistener ! http.unbind         complete("stopping server")        }      } 

anyway, want send http request /shutdown , have application down

the sender of bound message should spray listener, when receiving message can capture it.

you did not post full actor little different hope helps.

class mystarter extends actor {      // listener     var mylistener: actorref = _      override def prestart(): unit = {       implicit val system = context.system       io(http) ! http.bind(...)     }      override def receive: receive = {       case msg: bound =>         // when receive bound message sent listener         mylistener = sender()         ...       case ... => ...    } } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -