How to set up sbt to restart long-running server process upon code change?

StackOverflow https://stackoverflow.com/questions/3131162

  •  01-10-2019
  •  | 
  •  

Pergunta

Using the ~run command sbt will re-run an executable target for me whenever a source file changes. This is nice, but if the target is a long-running server process, sbt is suspended until the child terminates, so source changes have no effect.

I'd like to have sbt monitor and recompile my sources even while the target code is running, and restart the process on a successful build. Has anybody tried to set this up?

Foi útil?

Solução

(Sorry for the post-mortem reply)

https://github.com/spray/sbt-revolver has been created just to solve this problem.

Outras dicas

This is not possible via the built in "~" functionality. The problem is, that the "~"-prefixed task has to complete. If it is a server application listening on some ports, you have stop it first.

Maybe you could create your own task or modify the run task, to kill/quit the running application (e.g. sending a magic exit-string on the listening port?). See this for more information:

http://code.google.com/p/simple-build-tool/wiki/CustomActions

JRebel could help you with dynamic class reloading if that is what you are after. Free Scala licence avaliable here. Usage information at the SBT site.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top