Quantcast

[exec-maven-plugin] How to start a background process with exec:exec

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[exec-maven-plugin] How to start a background process with exec:exec

Andreas Sewe-2
Hi all,

in the "pre-integration-test" phase I am trying to start a background
process using exec:exec. While I am aware of the fact that the plugin
does not (yet) support the spawing of background processes directly
[1,2], I was surprised to see that the following workaround doesn't work:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
      <execution>
        <id>start-server</id>
        <phase>pre-integration-test</phase>
        <goals>
          <goal>exec</goal>
        </goals>
        <configuration>
          <executable>src/test/scripts/run.sh</executable>
          <arguments>
            <argument>{server.home}/bin/server</argument>
          </arguments>
        </configuration>
      </execution>
    </executions>
  </plugin>

The run.sh script mentioned above is straighforward:

  #! /bin/sh
  $* &
  exit 0

Alas, exec:exec still blocks. Can someone please explain to be why this
happens? The debug output looks OK to me:

[DEBUG] Executing command line: src/test/scripts/run.sh ./bin/server

Best wishes,

Andreas

[1] <http://jira.codehaus.org/browse/MEXEC-87>
[2] <http://jira.codehaus.org/browse/MEXEC-96>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [exec-maven-plugin] How to start a background process with exec:exec

Kelly Davis
Try changing the script to something like this: 

 #! /bin/sh
 $* > /dev/null 2>&1 &
 exit 0

http://www.xaprb.com/blog/2006/06/06/what-does-devnull-21-mean/

On Thu, Dec 8, 2011 at 9:26 AM, Andreas Sewe <[hidden email]> wrote:
Hi all,

in the "pre-integration-test" phase I am trying to start a background
process using exec:exec. While I am aware of the fact that the plugin
does not (yet) support the spawing of background processes directly
[1,2], I was surprised to see that the following workaround doesn't work:

 <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>exec-maven-plugin</artifactId>
   <version>1.2.1</version>
   <executions>
     <execution>
       <id>start-server</id>
       <phase>pre-integration-test</phase>
       <goals>
         <goal>exec</goal>
       </goals>
       <configuration>
         <executable>src/test/scripts/run.sh</executable>
         <arguments>
           <argument>{server.home}/bin/server</argument>
         </arguments>
       </configuration>
     </execution>
   </executions>
 </plugin>

The run.sh script mentioned above is straighforward:

 #! /bin/sh
 $* &
 exit 0

Alas, exec:exec still blocks. Can someone please explain to be why this
happens? The debug output looks OK to me:

[DEBUG] Executing command line: src/test/scripts/run.sh ./bin/server

Best wishes,

Andreas

[1] <http://jira.codehaus.org/browse/MEXEC-87>
[2] <http://jira.codehaus.org/browse/MEXEC-96>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [exec-maven-plugin] How to start a background process with exec:exec

Andreas Sewe-2
Kelly Davis wrote:
> Try changing the script to something like this:
>
>  #! /bin/sh
>  $* > /dev/null 2>&1 &
>  exit 0
>
> http://www.xaprb.com/blog/2006/06/06/what-does-devnull-21-mean/

Yes, that did the trick. Thank you very much. :-)

Alas, I have no idea the redirections are required here. Can you
enlighten me?

Best wishes,

Andreas

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [exec-maven-plugin] How to start a background process with exec:exec

Kelly Davis
If you don't care about the output, this will just send everything to /dev/null. If you want to log it, change it to something like this:

$* > /dev/null 2>err.log 1>out.log &

This directs stderr to err.log, stdout to out.log

On Thu, Dec 8, 2011 at 11:05 AM, Andreas Sewe <[hidden email]> wrote:
Kelly Davis wrote:
> Try changing the script to something like this:
>
>  #! /bin/sh
>  $* > /dev/null 2>&1 &
>  exit 0
>
> http://www.xaprb.com/blog/2006/06/06/what-does-devnull-21-mean/

Yes, that did the trick. Thank you very much. :-)

Alas, I have no idea the redirections are required here. Can you
enlighten me?

Best wishes,

Andreas

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [exec-maven-plugin] How to start a background process with exec:exec

Andreas Sewe-2
Kelly Davis wrote:
> If you don't care about the output, this will just send everything to
> /dev/null. If you want to log it, change it to something like this:
>
> $* > /dev/null 2>err.log 1>out.log &
>
> This directs stderr to err.log, stdout to out.log

I do know how redirections work.

What I did not know, however, was that I *have* to redirect STDOUT/ERR
in order for '&' not to block. That's kind of annoying if you would like
to see your server's output interspersed with Maven's output rather than
in a separate file.

Thanks anyway for your help.

Best wishes,

Andreas

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...