You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Odelya <od...@alicanto.com> on 2012/08/24 14:44:43 UTC

Running java jar from buildr - not starting

Hi!

In the end of my tasks, I would like to run java's jar.

I wrote the following:

sh "nohup java -jar  engine_dev.jar  \&> /var/log/engine/dev/startengine.log
\&"

And I see in the logs that the command is being executed:

nohup java -jar  engine_dev.jar  &> /var/log/engine/dev/startengine.log &

However, the jar does not start.

If I try "java -jar engine_dev.jar " - than the jar starts but in the same
terminal. (jenkins output) so I need the nohup so it will run even if
jenkins logs out of the shell.

If I try the same command with jenkins user (the one that runs buildr) in
the shell - it works just fine.

What could be the problem?



--
View this message in context: http://buildr-users.1056619.n5.nabble.com/Running-java-jar-from-buildr-not-starting-tp5706586.html
Sent from the Buildr Users mailing list archive at Nabble.com.

Re: Running java jar from buildr - not starting

Posted by Odelya Holiday <od...@alicanto.com>.
In case someone confronts the same problem:

Jenkins kills the process once finishes working

See here:

https://wiki.jenkins-ci.org/display/JENKINS/ProcessTreeKiller

In order to prevent this behaviour, you need to add the sh BUILD_ID env

e.g.

sh "$BUILD_ID=nohup java -jar  my.jar &"

On Sat, Aug 25, 2012 at 9:12 PM, Odelya <od...@alicanto.com> wrote:

> well I had to use nohup otherwise it will close when jenkins finishes its
> job
>
> So instead I did:
>
> sh "nohup java -jar  engine_dev.jar  >
> /var/log/engine/dev/startengine.log &" (my problem was the extra &
> before the >)
>
> On Fri, Aug 24, 2012 at 8:23 PM, Alex Boisvert [via Buildr Users]
> <ml...@n5.nabble.com> wrote:
> > Should work... you don't need to escape the ampersand and you shouldn't
> > need 'nohup'... try:
> >
> > sh "java -jar  engine_dev.jar  > /var/log/engine/dev/startengine.log &"
> >
> > On Fri, Aug 24, 2012 at 5:44 AM, Odelya <[hidden email]> wrote:
> >
> >> Hi!
> >>
> >> In the end of my tasks, I would like to run java's jar.
> >>
> >> I wrote the following:
> >>
> >> sh "nohup java -jar  engine_dev.jar  \&>
> >> /var/log/engine/dev/startengine.log
> >> \&"
> >>
> >> And I see in the logs that the command is being executed:
> >>
> >> nohup java -jar  engine_dev.jar  &> /var/log/engine/dev/startengine.log
> &
> >>
> >> However, the jar does not start.
> >>
> >> If I try "java -jar engine_dev.jar " - than the jar starts but in the
> same
> >> terminal. (jenkins output) so I need the nohup so it will run even if
> >> jenkins logs out of the shell.
> >>
> >> If I try the same command with jenkins user (the one that runs buildr)
> in
> >> the shell - it works just fine.
> >>
> >> What could be the problem?
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> >>
> http://buildr-users.1056619.n5.nabble.com/Running-java-jar-from-buildr-not-starting-tp5706586.html
> >> Sent from the Buildr Users mailing list archive at Nabble.com.
> >>
> >
> >
> > ________________________________
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://buildr-users.1056619.n5.nabble.com/Running-java-jar-from-buildr-not-starting-tp5706586p5706587.html
> > To unsubscribe from Running java jar from buildr - not starting, click
> here.
> > NAML
>
>
>
> --
> Odelya
>
>
>
>
> --
> View this message in context:
> http://buildr-users.1056619.n5.nabble.com/Running-java-jar-from-buildr-not-starting-tp5706586p5706593.html
> Sent from the Buildr Users mailing list archive at Nabble.com.
>



-- 
Odelya

Re: Running java jar from buildr - not starting

Posted by Odelya <od...@alicanto.com>.
well I had to use nohup otherwise it will close when jenkins finishes its job

So instead I did:

sh "nohup java -jar  engine_dev.jar  >
/var/log/engine/dev/startengine.log &" (my problem was the extra &
before the >)

On Fri, Aug 24, 2012 at 8:23 PM, Alex Boisvert [via Buildr Users]
<ml...@n5.nabble.com> wrote:
> Should work... you don't need to escape the ampersand and you shouldn't
> need 'nohup'... try:
>
> sh "java -jar  engine_dev.jar  > /var/log/engine/dev/startengine.log &"
>
> On Fri, Aug 24, 2012 at 5:44 AM, Odelya <[hidden email]> wrote:
>
>> Hi!
>>
>> In the end of my tasks, I would like to run java's jar.
>>
>> I wrote the following:
>>
>> sh "nohup java -jar  engine_dev.jar  \&>
>> /var/log/engine/dev/startengine.log
>> \&"
>>
>> And I see in the logs that the command is being executed:
>>
>> nohup java -jar  engine_dev.jar  &> /var/log/engine/dev/startengine.log &
>>
>> However, the jar does not start.
>>
>> If I try "java -jar engine_dev.jar " - than the jar starts but in the same
>> terminal. (jenkins output) so I need the nohup so it will run even if
>> jenkins logs out of the shell.
>>
>> If I try the same command with jenkins user (the one that runs buildr) in
>> the shell - it works just fine.
>>
>> What could be the problem?
>>
>>
>>
>> --
>> View this message in context:
>>
>> http://buildr-users.1056619.n5.nabble.com/Running-java-jar-from-buildr-not-starting-tp5706586.html
>> Sent from the Buildr Users mailing list archive at Nabble.com.
>>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://buildr-users.1056619.n5.nabble.com/Running-java-jar-from-buildr-not-starting-tp5706586p5706587.html
> To unsubscribe from Running java jar from buildr - not starting, click here.
> NAML



-- 
Odelya




--
View this message in context: http://buildr-users.1056619.n5.nabble.com/Running-java-jar-from-buildr-not-starting-tp5706586p5706593.html
Sent from the Buildr Users mailing list archive at Nabble.com.

Re: Running java jar from buildr - not starting

Posted by Alex Boisvert <al...@gmail.com>.
Should work... you don't need to escape the ampersand and you shouldn't
need 'nohup'... try:

sh "java -jar  engine_dev.jar  > /var/log/engine/dev/startengine.log &"

On Fri, Aug 24, 2012 at 5:44 AM, Odelya <od...@alicanto.com> wrote:

> Hi!
>
> In the end of my tasks, I would like to run java's jar.
>
> I wrote the following:
>
> sh "nohup java -jar  engine_dev.jar  \&>
> /var/log/engine/dev/startengine.log
> \&"
>
> And I see in the logs that the command is being executed:
>
> nohup java -jar  engine_dev.jar  &> /var/log/engine/dev/startengine.log &
>
> However, the jar does not start.
>
> If I try "java -jar engine_dev.jar " - than the jar starts but in the same
> terminal. (jenkins output) so I need the nohup so it will run even if
> jenkins logs out of the shell.
>
> If I try the same command with jenkins user (the one that runs buildr) in
> the shell - it works just fine.
>
> What could be the problem?
>
>
>
> --
> View this message in context:
> http://buildr-users.1056619.n5.nabble.com/Running-java-jar-from-buildr-not-starting-tp5706586.html
> Sent from the Buildr Users mailing list archive at Nabble.com.
>