Handling ctrl+c in sbt shell

Hi everyone,

I am new to Akka HTTP and the first problem I encountered is how to handle ctrl+c in sbt shell to stop my Akka HTTP application running. After ctrl+c in sbt shell, I cannot run my Akka HTTP application again because it says that “java.net.BindException: [localhost/127.0.0.1:8000] Address already in use”. I believe that I need to implement a graceful shutdown hook for my jvm process running in sbt shell but the documents on the net (and akka http) did not help. I would be happy if one of you let me know how to write a shudown hook for my Akka HTTP application so that I can rerun my application again after ctrl+c, this will help me solve the issue of “java.net.BindException: [localhost/127.0.0.1:8000] Address already in use”.

Best wishes,
-halil.

snt captures ctrl-c in a way that is not propagated to the application in a ”normal” way. You can try what we used here: akka-platform-guide/build.sbt at 680b88c71e0c9e38c2fbb4cdfa39b3aec95e7f30 · akka/akka-platform-guide · GitHub