scalacenter / bloop

Bloop is a build server and CLI tool to compile, test and run Scala fast from any editor or build tool.
https://scalacenter.github.io/bloop/
Apache License 2.0
907 stars 201 forks source link

Add restarting mode to `bloop run --watch` #558

Open guersam opened 6 years ago

guersam commented 6 years ago

Currently, bloop run --watch only works for self-terminating apps so that it's not applicable for non-terminating apps such as servers.

What about adding an option to kill the forked vm and restart it when a source file change is detected? This feature would be drop-in replacement of https://github.com/spray/sbt-revolver.

jvican commented 6 years ago

Thanks for opening this ticket Jisco. I agree this is valuable and would love to see it available in a release soon. Feel free to give it a try, I don't think the changes will be big because we already support cancellation of forked processes via Monix.

tindzk commented 6 years ago

This is a duplicate of https://github.com/scalacenter/bloop/issues/475.

jvican commented 6 years ago

Is it? You didn't specify that your application was still running and you were expecting bloop to kill the JVM and restart it. If it is, let's close #475 in favor of this ticket that is clearer about the goal and more actionable.

svalaskevicius commented 5 years ago

btw this can be worked around with some tools :) http://eradman.com/entrproject/

fd scala | entr -r bloop run ...

jvican commented 5 years ago

Nice :smile:

I'd like to implement this for the CLI at some point too, but if I can avoid developing/maintaining it the better. Thanks for sharing that incantation!

On the IDE side (Metals/IntelliJ), a way to emulate the behavior expected in the ticket is to have the build clients send a BSP buildTarget/run request to a file whenever there are are changes in a file in the editor.

svalaskevicius commented 5 years ago

Bloop starts up quickly (thanks for that!), so using entr for this is actually quite ok usability-wise.

Also, the Unix philosophy.. :)

davojan commented 5 years ago

The only downside of the entr workaround is that whenever you add new a new source file, it won't be watched. So native support of killing daemons will work a little better.

@svalaskevicius big thanks for this solution.

dkovalenko commented 4 years ago

+1 for this issue, without it there's no way to iterate fast with server development.

kubukoz commented 4 years ago

@dkovalenko if you need to iterate that fast, maybe you should write a test instead of starting an entire server ;)

On a more serious note (or is it?), I'd also appreciate this feature.

kubukoz commented 2 months ago

For scala-cli users, I think this is available as --revolver. Still, would be lovely for direct bloop usage e.g. in sbt+metals builds.