Best way of restarting a jetty instance

14,554

Can you write a shell script that does something like this after calling shutdown and before calling startup?


LISTEN_PORT = `netstat -vatn | grep LISTEN| grep 8080 | wc -l `
while [$LISTEN_PORT -ne 0] ; do
    sleep 1
    LISTEN_PORT = `netstat -vatn | grep LISTEN| grep 8080 | wc -l `
done
Share:
14,554
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin about 2 years

    I'm using start.jar and stop.jar to stop and start my jetty instance. I restart by calling stop.jar, then start.jar. The problem is, if I don't sleep long enough between stop.jar and start.jar I start getting these random ClassNotFoundExceptions and the application doesn't work correctly.

    Sleeping for a longer period of time between stop and start is my current option.

    I also heard from someone that I should have something that manages my threads so that I end those before jetty finishes. Is this correct? The question I have about this is that stop.jar returns immediately, so it doesn't seem to help me, unless there's something I'm missing. Another option might be to poll the log file, but that's pretty ugly.

    What's the best way of restarting jetty?

    Gilbert: The Ant task is definitely not a bad way of doing it. However, it sleeps for a set amount of time, which is exactly what I'm trying to avoid.