Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Ant task to start/shutdown jboss

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I am trying to start/shutdown jboss from and Ant build script. I am also using custom server configuration specified by proper Java jboss properties.

Here is the start task:

If jboss is already running, then it should not try to start jboss again.

This works but the first time I start jboss I still get the echo message "JBoss is already running on..." while it is not.

1) How can I avoid that echo print the first time I start jboss?

The second question is about the shutdown task:

The problem is that I don't get any error but the jboss instance is still running properly...

2) What is wrong with my script? How can I actually stop the instance I started with the previous task?

3 (and last) question: how can I run those two tasks and show the jboss log on the console?

I look forward to hearing from you.

Cheers,
Giovanni
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) When you call a target, all tasks in the target get executed. That is why the echo always runs. Instead, do something like this:



Doing this causes the check to be made for JBoss AS running first, and then the "check_jboss_running" target gets run only i8f JBoss AS is running.

2) I assume that you echoed the java command line that gets run by the shutdown script and your java task merely imitates that. Try running the ant script with the -v option and see if you get more info on exactly what Ant ran and make sure it matches what the shutdown script runs.

3) I do not think this is possible. The only options I see for the java task is 'output' which lets to specify a file for stdout/stderr, and 'outputproperty' which lets your catch the stdout/stderr text in an ant property. My suggestion is to use 'output' and then use a utility such as 'tail -f' to monitor the contents of the file.
 
Giovanni De Stefano
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Peter,

thank you very much for your help.

Thanks to your advice I have been able to reach my goals :-)

I report here my code including your changes for anyone else who might need something similar.

Cheers,
Giovanni
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic