Most appropriate method to persist a sbt process after exiting SSH session?

后端 未结 3 479
鱼传尺愫
鱼传尺愫 2021-01-22 22:59

How do I keep a process, specifically one spawned via the sbt command, alive after exiting my ssh session? The following related questions [1], [2], [3

相关标签:
3条回答
  • 2021-01-22 23:21

    It looks like SBT hanging in the background is a JLine issue. There is a workaround:

    sbt -Djline.terminal=jline.UnsupportedTerminal about &
    

    Just add this flag to any SBT command you want to run in the background.

    0 讨论(0)
  • 2021-01-22 23:35

    It is not a easy task to put sbt run as a daemon.
    Most suggestions are using sbt-assembly.

    If you donot want to using sbt-assembly, you may first package you scala application, then run it with scala command.

    For me, the commands are, in this way, scala will continue to run after you exit ssh:

    sbt clean package
    nohup scala ./target/scala-2.10/trafficgenerator_2.10-1.0.jar &
    
    0 讨论(0)
  • 2021-01-22 23:37

    It is even more common. Try to type sbt clean & or sbt compile &. Proccess is created but it won't finish.

    Solution for your question by using tmxux:

    tmux new -d -s $$ && tmux send -t $$ 'SHELL_COMMAND' ENTER
    

    In your context SHELL_COMMAND = sbt -Dgeotrellis cluster_seed_ip=xxx.xxx.xxx.xxx

    You can also use tmux behind byobu:

    byobu new -d -s $$ && tmux send -t $$ 'SHELL_COMMAND' ENTER
    

    After that if you type byobu then you enter session of your command.

    0 讨论(0)
提交回复
热议问题