This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

graceful windows command line shutdown

 
Trailboss
Posts: 22974
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can hit ctrl-c with the best of them. When I do this, I see a bunch of messages about things gone bad and then a window pops up wanting to know if I want to notify microsoft about my system problems.

I would like to make a batch file that I could put in my project called bounce.bat. It would tell tomcat to gracefully shutdown and block until tomcat was all done. Then it would call "ant deploy" - where I would pretty much delete everything in the tomcat webapps directory, then drop a fresh war file. Then it would start tomcat back up.

Is this too much to ask?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's one that I use.
It does it the opposit way from what you just described (the ant script calls the shell/batch script)
Like yourself, I feel more comfortable with a complete shutdown of Tomcat.
Since I'm doing that, I never needed to install the ANT tasks for deploying.

This script probably does more than what you want so you'll have to weed out what's junk to you:

It:
  • Deletes the current copy of the application
  • Pulls the entire project from CVS to the scratch directory
  • Does some string replacement (version numbers, connection strings, etc)
  • Compiles all the Java classes (by calling nested build scripts)
  • Jars up all the class files and deletes the source (this removes the temptation to make a fix on the build server instead of doing in the developer's environment and checking it into CVS)
  • Packs everything into a war file.
  • Calls a shell script that restarts Tocmat

  • CD tomcat/bin
    ./shutdown.sh
    ./startup.sh
  • Sleeps for a while, giving tomcat a chance to wake up and deploy the new war file.
  • Moves some non-shipping files into directories within the app.
  • Says "done"


  • sample.build.xml
    I'm sure an ANT guru could show me better ways to do some of this stuff but it does what I need.


    At least one of the tags was a problem for the forum software and it would have been too time consuming to figure out which so I provided a link to it instead.


    For a winders box you just need to change the ./startup.sh to startup etc.
    Or... If you're running Tomcat as a service, you can use:
    net stop TOMCAT_SERVICE_NAME
    net start TOMCAT_SERVICE_NAME
    [ January 13, 2006: Message edited by: Ben Souther ]
     
    paul wheaton
    Trailboss
    Posts: 22974
    IntelliJ IDE Firefox Browser Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    do you have a shutdown and startup for windows?
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser VI Editor Redhat
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator



    Or, if you're running Tomcat as a service.


    You can get the service name by looking in the properties window from the services screen. I just looked on one of our windows boxes and it's "Tomcat5"
    [ January 13, 2006: Message edited by: Ben Souther ]
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser VI Editor Redhat
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Graceful would be a stretch but it is thorough.
     
    Author and all-around good cowpoke
    Posts: 13078
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I have a question about running shutdown.bat immediately followed by startup.bat
    Typically my Tomcat takes quite a while to go through the shutdown routine so I always wait till it vanishes from the processes list. Is it safe to start a new instance with startup.bat while the old one is still shutting down?
    Bill
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser VI Editor Redhat
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I do it all the time with the shell scripts in Linix.
    The new one runs under a different process.
    I can't say for sure with Windows.

    If it is a problem, you could always run the shutdown script, then build the project before calling startup.
    Or, use Ant's sleep task to insure that there is some time between the two.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!