[arquillian-issues] [JBoss JIRA] (ARQ-1841) Spacelift can not deal with background process invocation

Stefan Miklosovic (JIRA) issues at jboss.org
Tue Aug 19 08:43:32 EDT 2014


     [ https://issues.jboss.org/browse/ARQ-1841?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Miklosovic updated ARQ-1841:
-----------------------------------

    Description: 
Let's have this simple script:

{code:title=run_agent_bg.sh|borderStyle=solid}
#!/bin/sh
curpath=`dirname $0`
nohup ${curpath}/run_agent.sh $@ > /dev/null & 2>&1
{code}

I execute it like this:

{code:title=App.java|borderStyle=solid}
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");
    }
}
{code}

So it effectively does this:

{code}
/bin/bash -c "/tmp/ngrinder-agent/ngrinder-agent/run_agent_bg.sh"
{code}

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:

{code:title=App.java|borderStyle=solid}
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");
    }
}
{code}

Started process survives JVM termination.

  was:
Let's have this simple script:

{code}
#!/bin/sh
curpath=`dirname $0`
nohup ${curpath}/run_agent.sh $@ > /dev/null & 2>&1
{code}

I execute it like this:

{code}
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");
    }
}
{code}

So it effectively does this:

{code}
/bin/bash -c "/tmp/ngrinder-agent/ngrinder-agent/run_agent_bg.sh"
{code}

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:

{code}
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");
    }
}
{code}

Started process survives JVM termination.



> Spacelift can not deal with background process invocation
> ---------------------------------------------------------
>
>                 Key: ARQ-1841
>                 URL: https://issues.jboss.org/browse/ARQ-1841
>             Project: Arquillian
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Extension - Spacelift
>    Affects Versions: spacelift_1.0.0.Alpha2
>            Reporter: Stefan Miklosovic
>
> Let's have this simple script:
> {code:title=run_agent_bg.sh|borderStyle=solid}
> #!/bin/sh
> curpath=`dirname $0`
> nohup ${curpath}/run_agent.sh $@ > /dev/null & 2>&1
> {code}
> I execute it like this:
> {code:title=App.java|borderStyle=solid}
> 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");
>     }
> }
> {code}
> So it effectively does this:
> {code}
> /bin/bash -c "/tmp/ngrinder-agent/ngrinder-agent/run_agent_bg.sh"
> {code}
> 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:
> {code:title=App.java|borderStyle=solid}
> 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");
>     }
> }
> {code}
> Started process survives JVM termination.



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)


More information about the arquillian-issues mailing list