Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sbt

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?

like image 726
Crosbie Avatar asked Jun 28 '10 09:06

Crosbie


2 Answers

(Sorry for the post-mortem reply)

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

like image 171
Carlos Ferreyra Avatar answered Dec 07 '22 02:12

Carlos Ferreyra


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

like image 31
michael.kebe Avatar answered Dec 07 '22 03:12

michael.kebe