3

I want to launch scalatra server from sbt. How do I do that? The following does launch scalatra:

sbt "container:start"

But it exits immediately:

[info] starting server ...
[success] Total time: 2 s, completed Sep 12, 2015 2:39:32 PM
> [info] waiting for server to shut down...

Most preferably the whole thing would run in a nohup as a daemon process.

WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560

2 Answers2

3
sbt "; <command>; console"

does the trick. Note the initial semicolon is required.

WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560
2

Don't do it on one line. Use two commands.

./sbt
container:start
avanti
  • 129
  • 6
  • Hi avanti. Is your suggestion here addressing starting sbt as a daemon? – WestCoastProjects Sep 12 '15 at 23:58
  • If you want to start your scalatra app as a daemon you should use Jetty or another web server. `sbt` is a build tool. It will open a new command process in the foreground and while it's there you can run commands such as `container:start` which launches your scalatra app and keeps it running. However, this is not an appropriate way to launch a scalatra app in anything other than a local development environment. – avanti Sep 13 '15 at 00:05
  • You said "I want to launch scalatra server from sbt [and keep it running]". That's how you do it. If you want more info on running a scalatra app outside of sbt, ask that question and I'll write up an answer. – avanti Sep 13 '15 at 00:13
  • Thx Avanti. I updated the question. I had also already said "Most preferably the whole thing would run in a nohup as a daemon process." If it were really true that sbt does not allow running as a daemon then i can award your question. i will look further into it. – WestCoastProjects Sep 13 '15 at 04:53
  • 1
    Here's a way to daemonize the sbt process: http://stackoverflow.com/questions/6000362/running-sbt-as-daemon?lq=1 – avanti Sep 13 '15 at 16:38