Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
spacelift_1.0.0.Alpha2
-
None
Description
Let's have this simple script:
run_agent_bg.sh
#!/bin/sh
curpath=`dirname $0`
nohup ${curpath}/run_agent.sh $@ > /dev/null & 2>&1
I execute it like this:
App.java
public class App { public static void main(String[] args) throws IOException { Tasks.setDefaultExecutionServiceFactory(new DefaultExecutionServiceFactory()); System.out.println("before"); Tasks.prepare(CommandTool.class) .programName("/bin/bash") .parameters("-c", "/tmp/ngrinder-agent/ngrinder-agent/run_agent_bg.sh") .execute().await(); System.out.println("after"); } }
So it effectively does this:
/bin/bash -c "/tmp/ngrinder-agent/ngrinder-agent/run_agent_bg.sh"
However it never reaches "after" output, that process in the script is started but Spacelift does not send it to the background and it still waits untill it is finished which never happen.
Executing that script directly like following does the job:
App.java
public class App { public static void main(String[] args) throws IOException { Tasks.setDefaultExecutionServiceFactory(new DefaultExecutionServiceFactory()); System.out.println("before"); Runtime.getRuntime().exec("/tmp/ngrinder-agent/ngrinder-agent/run_agent_bg.sh"); System.out.println("after"); } }
Started process survives JVM termination.