Tomcat 6 processes won't die when stopped, with Railo 3.1?

1,573 views
Skip to first unread message

Jamie Krug

unread,
Apr 30, 2009, 9:39:57 PM4/30/09
to Railo
After finalizing (or so I thought) my production-ready Linux/Apache/
Tomcat/Railo configuration plans, I stumbled upon a disturbing issue.
When I stop Tomcat (tomcat/bin/shutdown.sh), the process does not die
and the memory is not released. This means that if I restart my Tomcat
service 10 times without rebooting, then I have 10 processes hanging
out there, and my memory usage just keeps growing and growing!

Once I noticed this problem, I was sure to isolate a test and I can
confirm that this is, unfortunately, easily reproduced. Here's what I
did on my Ubuntu 8.04 Desktop to test...

I downloaded and extracted the Tomcat 6.0.18 .tar.gz file into a
"tomcat-test" folder in my home directory. I ran a cycle of start (~/
tomcat-test/bin/startup.sh), test (http://localhost:8080/) and stop (~/
tomcat-test/bin/shutdown.sh). After starting Tomcat I noted the
running process (using the "ps -ef" command to view all running
processes). After stopping Tomcat I noted that the process was no
longer listed as a running process. I repeated this once more, to be
sure.

Next I downloaded and extracted the Railo 3.1.0.012 WAR, deleted all
directories under ~/tomcat-test/webapps/, and moved/renamed the Railo
WAR as the ROOT directory under webapps. Once again I ran a few cycles
of start/test/stop of the Tomcat service. This time the processes just
piled up. Each time I stopped Tomcat, it did _appear_ to stop, because
the test page returned a 404 as expected, but the process was still
listed as running and eating up some RAM for every start of Tomcat.

Again, if I start/stop Tomcat (with Railo) 10 times, I have 10 running
processes and 10 times the RAM usage, but no Tomcat/Railo running. The
only way to get rid of those processes is to reboot or use manual kill
commands for each PID.

I should also note that I'm using the latest Sun Java JDK 6 Update 13
for the JVM.

Has anyone else noticed this issue? On other OSes? On other servlet
engines?

If I have time soon, I'll try Resin or another servlet engine and see
what happens. Any other thoughts/suggestions?

Thanks,
Jamie

Jamie Krug

unread,
Apr 30, 2009, 9:52:09 PM4/30/09
to Railo
I've also ran the same tests with Railo 3.0.2.001 on Tomcat 6.0.18 and
received the same results -- processes that just don't die!

I also found another tid-bit. After I shutdown Tomcat and hit
http://localhost:8080 I see the Tomcat 404 error page, which suggests
that Tomcat is still (sorta?) running, though it's not serving up the
index page. Once I manually kill the lingering processes, I then get
the expected "Failed to connect" screen from Firefox.

Best,
Jamie

Dave

unread,
Apr 30, 2009, 9:59:23 PM4/30/09
to ra...@googlegroups.com
I see this on os x a lot, it's actually the bootstrap that does this.
I have been able to fix it by doing a permissions repair on the system.
When it does do it you need to force quit it.
As far as I can tell it is caused by your tomcat startup script.

Jamie Krug

unread,
Apr 30, 2009, 10:17:08 PM4/30/09
to ra...@googlegroups.com
Dave,

I'm just using the startup.sh script that is bundled with Tomcat 6.0.18. The startup/shutdown of Tomcat works fine on its own, but once the Railo WAR is in there, the processes just don't die after the shutdown.sh call.

I'm not sure what you mean by "a permissions repair on the system," but I purposely tested this in my home directory where I'm running everything as owner of that file system. In fact, to be safe, I just opened up complete permissions to my test Tomcat directory (chmod -R 777) and have the same problem.

I'm also tested with Java 1.6.0_07 as the JRE -- same problem.

I did *not* have a problem when testing the Railo Express for 3.1, for Linux w/JRE. I'll try Resin and/or JBoss over the weekend, maybe.

Thanks,
Jamie

Dave

unread,
Apr 30, 2009, 10:38:30 PM4/30/09
to ra...@googlegroups.com
here is a screenie of what happens on mine.. well when I can tell the permissions have bad.

I'm not sure how that startup script works on linux, I made a startup script

You might want to try installing the tomcat native library which is supposed to be done for production servers which helps performance.

you can read what I did here:

When I repair permissions I just select my partition and and run a repair permissions, again thats on a mac so not sure what linux does.
Also I don't think the permissions should be 777, i believe they should be 644.

I would check here to:

Maybe even check and add more allowance for java system or tomcat memory. How much memory does your railo admin say you are using?

Barney Boisvert

unread,
May 1, 2009, 1:44:12 AM5/1/09
to ra...@googlegroups.com
This isn't a Railo-specific issue. I have the same problem with a
CFML-free Tomcat on my box (running CentOS 4). Whether it's a Tomcat
issue or an issue with certain web apps (like Railo), I can't say.
That Tomcat is running an older Magnolia (3.1-ish), but nothing beyond
that. Could be some library that both Railo and Magnolia use, or just
a specific coding idiom that prevents the shutdown. Perhaps just
being from Switzerland? :)

I don't restart that instance very often so I just kill the lingering
server manually, but it'd be straightforward to add a little snippet
to the top of the startup script that will kill any already-running
processes of the same Tomcat instance. The process command line
contains path information, so you can narrow with grep, pull the
process ID with cut, and then pipe it to kill.

cheers,
barneyb
--
Barney Boisvert
bboi...@gmail.com
http://www.barneyb.com/

Jamie Krug

unread,
May 1, 2009, 9:48:47 AM5/1/09
to ra...@googlegroups.com
Barney,

Thanks for the feedback. At least I now know this issue is neither Railo nor Ubuntu specific. I'm still a bit new to Linux, but I'll try to take your suggestions regarding grep/cut/kill and see if I can tweak my init.d script to account for this anomaly.

Thanks,
Jamie

Terry Schmitt

unread,
May 1, 2009, 11:21:58 AM5/1/09
to Railo
I ran into this about a year ago with Ubuntu 8.04 and Tomcat 6. I
shelved the project, but have recently started again with Tomcat and
Ubuntu. Same problem. I agree, it's not related to Railo. Googling has
shown complaints with other applications, but I've never seen a
solution and killing processes is not my idea of a solution. I'd be
willing to bet that many people never notice this issue if they only
restart Tomcat during reboots. I noticed it after repeated restarts of
Tomcat had used up all my memory.
What I found is that if I launch Tomcat straight from the console, as
myself or my "tomcat" user, it starts and stops properly. No hanging
processes left over afterward. When I start from /etc/init.d/ it won't
shut down.

My solution? I'm testing Glassfish and quite content with it so far.

Terry

On May 1, 6:48 am, Jamie Krug <jamiek...@gmail.com> wrote:
> Barney,
>
> Thanks for the feedback. At least I now know this issue is neither Railo nor
> Ubuntu specific. I'm still a bit new to Linux, but I'll try to take your
> suggestions regarding grep/cut/kill and see if I can tweak my init.d script
> to account for this anomaly.
>
> Thanks,
> Jamie
>
> >http://books.google.com/books?id=d_FdV6JUZrgC&pg=PA396&lpg=PA396&dq=a...
> > >> >http://localhost:8080I see the Tomcat 404 error page, which suggests
> > bboisv...@gmail.com
> >http://www.barneyb.com/
>
>

Jamie Krug

unread,
May 1, 2009, 2:40:15 PM5/1/09
to ra...@googlegroups.com
@Terry,

I've noted slightly different behavior. I first noted the problem when using an init.d script, which was very simple and essentially just called the Tomcat startup.sh/shutdown.sh scripts. However, I also tested it in an isolated environment, as described in my first post, and I see the same problem even when starting Tomcat straight from the terminal as myself (and that was with Tomcat under my home directory, so no permission concerns).

I do have a pretty simple "kill" solution to try. I've dug into the scripts a bit more and see an easy place to kill the process -- the catalina.sh script that comes with Tomcat already has a kill option. The startup.sh/shutdown.sh scripts are essentially just calling the catalina.sh script with a "start" or "stop" option. Looking through the catalina.sh script, I noticed that there's a "-force" option that you can pass when stopping (e.g., /opt/tomcat6/bin/catalina.sh stop -force), which is a stop followed by a kill. I was thinking about rewriting my own version of catalina.sh anyway, because there is a lot of superfluous scripting in there to make it work with a bunch of different UNIX-like OSes. So, I think I'll strip out the extra junk and do a brief sleep after a stop and then kill the process as well.

I may have to give Glassfish a peak as well. I've also tried Ubuntu 8.10 and 9.04, which have Tomcat 6 in the repos. They have a nice, simple "apt-get install tomcat6" option, and you have the init.d taken care of as well as Linux-friendly file locations for logs, scripts, configs, etc. Unfortunately, I could not get Railo running at all. First, it was Java security issues, which I figured out, but then I was still getting "class not defined" errors for classes that were clearly there. It didn't mention any other Java security issues, and I tried giving just about all permissions possible, just to get it to work. I also ensured that it was not a file permissions issue, but no luck at all. I didn't spend a ton of time on it, but it just didn't seem worth it.

@Barney,

Out of curiosity, how do you have Tomcat setup on your CentOS server? Is it a CentOS-provided package, or are you manually configuring your own init script and just grabbing the latest Tomcat .tar.gz from the Apache site? I think I recall you have multiple Tomcat instances running too? Are those sharing a single Tomcat library and just starting as separate services, or just multiple copies of the Tomcat download?

@Railo Team,

I know the question has been floated before, but I'm anxious to know what plans might be in the works for Railo/JBoss installation/documentation. So far, there's a lot of good information out for running Railo in a variety of configurations for development purposes, but I'm also looking to handle the production-ready administration myself as well, and I'm struggling a bit. It seems like a solid production setup of Railo on JBoss/Tomcat for Linux might go a long way for the Railo/CFML community :) Or, maybe I'm just trying too hard to moonlight as a wanna-be-Linux-admin in addition to wearing my programmer's hat :)

Thanks all!
Jamie

Barney Boisvert

unread,
May 1, 2009, 2:44:25 PM5/1/09
to ra...@googlegroups.com
Just unzip the binary distro to a folder, and symlink to catalina.sh
from /etc/init.d/tomcat_XXX. Have to add the chkconfig comment lines
to the top of the script, but that's it. I don't do the shared
binaries (splitting CATALINA_HOME and CATALINA_BASE) because disk
space is cheap, and I want to be able to upgrade separately. Just
unzip a new copy of the distro for each instance, obviously tweaking
server.xml to avoid port collisions and such. Then I front them all
with Apache (using mod_proxy) to stich them together into a single
unified webroot (along with some JRun-managed paths).

cheers,
barneyb

On Fri, May 1, 2009 at 11:40 AM, Jamie Krug <jami...@gmail.com> wrote:
> @Barney,
>
> Out of curiosity, how do you have Tomcat setup on your CentOS server? Is it
> a CentOS-provided package, or are you manually configuring your own init
> script and just grabbing the latest Tomcat .tar.gz from the Apache site? I
> think I recall you have multiple Tomcat instances running too? Are those
> sharing a single Tomcat library and just starting as separate services, or
> just multiple copies of the Tomcat download?
>

--

Jamie Krug

unread,
May 1, 2009, 3:24:22 PM5/1/09
to ra...@googlegroups.com
@Barney,

Thanks, great stuff. I'm loving the AJP proxy stuff that I gathered from your comment on Sean's blog (and subsequent post). It took a little more learning in the URL rewriting world, but I know have some preexisting (fairly complex) rewrite rules working in conjunction with a rewrite/proxy (AJP) to Tomcat/Railo for one app. I like the idea of simply unzipping the distro folder for multiple instances, and it's good to just know that someone else is doing it that way :)

Thanks again,
Jamie

Jamie Krug

unread,
May 4, 2009, 3:59:15 PM5/4/09
to Railo
Okay, here's the "production ready" init.d script I'll be using on my
Ubuntu 8.04 server. It could be very easily tweaked for other Linux
distros. Basically, I started with the /etc/init.d/skeleton "template"
script as a model and just added a hook to manually kill the Tomcat
process (PID) if the stop doesn't end the process as expected.

FYI, I've located my Tomcat home (latest binary distro extracted)
directory at /opt/tomcat6. Also, I'm running the daemon as an
unprivileged "tomcat6" user, so you'll want to create that group and
user first ("sudo groupadd tomcat6 && sudo useradd -g tomcat6
tomcat6").

After creating the following script as /etc/init.d/tomcat6 you can
also automatically configure this to automatically start and stop at
the proper times by issuing the following command (make sure ending
dot/period remains):
sudo update-rc.d tomcat6 start 92 2 3 4 5 . stop 08 0 1 6 .

#!/bin/sh
### BEGIN INIT INFO
# Provides: tomcat6
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Tomcat.
# Description: Start the Tomcat servlet engine.
### END INIT INFO

# Author: Jamie Krug <ja...@thekrugs.com>
# Written: May 4, 2009

PATH=/usr/sbin:/usr/bin:/sbin:/bin
NAME=tomcat6
DESC="Tomcat servlet engine"
TOMCAT_HOME=/opt/$NAME
PIDFILE=$TOMCAT_HOME/work/$NAME.pid
DAEMON=$TOMCAT_HOME/bin/catalina.sh
TOMCAT_USER=$NAME
JAVA_HOME=/usr

export JAVA_HOME

# This allows the Tomcat startup script to create a PID file:
export CATALINA_PID="$PIDFILE"

# Read configuration variable file if it is present
#[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
if start-stop-daemon --test --start --pidfile "$PIDFILE" \
--user $TOMCAT_USER --startas "$JAVA_HOME/bin/java" \
>/dev/null; then
su $TOMCAT_USER $DAEMON start
sleep 5
if start-stop-daemon --test --start --pidfile "$PIDFILE" \
--user $TOMCAT_USER --startas "$JAVA_HOME/bin/java" \
>/dev/null; then
log_end_msg 1
else
log_end_msg 0
fi
else
log_progress_msg "(already running)"
log_end_msg 0
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
if start-stop-daemon --test --start --pidfile "$PIDFILE" \
--user $TOMCAT_USER --startas "$JAVA_HOME/bin/java" \
>/dev/null; then
log_progress_msg "(not running)"
else
su $TOMCAT_USER $DAEMON stop
sleep 5
if start-stop-daemon --test --start --pidfile "$PIDFILE" \
--user $TOMCAT_USER --startas "$JAVA_HOME/bin/java" \
>/dev/null; then
log_progress_msg "(stop succeeded, no need to kill PID.)"
else
log_progress_msg "(stop failed, forcing kill of PID `cat
$PIDFILE`)"
kill -9 `cat $PIDFILE`
fi
fi
rm -f $PIDFILE
log_end_msg 0
;;
restart|force-reload)
if start-stop-daemon --test --stop --pidfile "$PIDFILE" \
--user $TOMCAT_USER --startas "$JAVA_HOME/bin/java" \
>/dev/null; then
$0 stop
sleep 1
fi
$0 start
;;
status)
if start-stop-daemon --test --start --pidfile "$PIDFILE" \
--user $TOMCAT_USER --startas "$JAVA_HOME/bin/java" \
>/dev/null; then
if [ -f "$PIDFILE" ]; then
log_success_msg "$DESC is not running, but pid file exists."
exit 1
else
log_success_msg "$DESC is not running."
exit 3
fi
else
log_success_msg "$DESC is running with pid `cat $PIDFILE`"
fi
;;
*)
log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
;;
esac

exit 0


Best,
Jamie

On May 1, 3:24 pm, Jamie Krug <jamiek...@gmail.com> wrote:
> @Barney,
>
> Thanks, great stuff. I'm loving the AJP proxy stuff that I gathered from
> your comment on Sean's blog (and subsequent post). It took a little more
> learning in the URL rewriting world, but I know have some preexisting
> (fairly complex) rewrite rules working in conjunction with a rewrite/proxy
> (AJP) to Tomcat/Railo for one app. I like the idea of simply unzipping the
> distro folder for multiple instances, and it's good to just know that
> someone else is doing it that way :)
>
> Thanks again,
> Jamie
>
> On Fri, May 1, 2009 at 2:44 PM, Barney Boisvert <bboisv...@gmail.com> wrote:
>
> > Just unzip the binary distro to a folder, and symlink to catalina.sh
> > from /etc/init.d/tomcat_XXX.  Have to add the chkconfig comment lines
> > to the top of the script, but that's it.  I don't do the shared
> > binaries (splitting CATALINA_HOME and CATALINA_BASE) because disk
> > space is cheap, and I want to be able to upgrade separately.  Just
> > unzip a new copy of the distro for each instance, obviously tweaking
> > server.xml to avoid port collisions and such.  Then I front them all
> > with Apache (using mod_proxy) to stich them together into a single
> > unified webroot (along with some JRun-managed paths).
>
> > cheers,
> > barneyb
>
> > On Fri, May 1, 2009 at 11:40 AM, Jamie Krug <jamiek...@gmail.com> wrote:
> > > @Barney,
>
> > > Out of curiosity, how do you have Tomcat setup on your CentOS server? Is
> > it
> > > a CentOS-provided package, or are you manually configuring your own init
> > > script and just grabbing the latest Tomcat .tar.gz from the Apache site?
> > I
> > > think I recall you have multiple Tomcat instances running too? Are those
> > > sharing a single Tomcat library and just starting as separate services,
> > or
> > > just multiple copies of the Tomcat download?
>
> > --
> > Barney Boisvert
> > bboisv...@gmail.com
> >http://www.barneyb.com/

denstar

unread,
May 4, 2009, 9:41:10 PM5/4/09
to ra...@googlegroups.com
By the by (bye the bye? eh), I recall that before I was binding JBoss
to specific IPs, sometimes shutting down wouldn't work.

Then I started binding the IP, and when I do the shutdown, passing
that IP as a parameter-- haven't had problems since.

Probably unrelated, but there you go.

Something like ($instance_host is IP variable):

$jboss_home/bin/shutdown.sh -s $instance_host -S

Yup, probably unrelated, but, well, can't hurt to put that out there, I guess.

-denner

--
I am what is mine. Personality is the original personal property.
Norman O. Brown

Jamie Krug

unread,
May 5, 2009, 10:37:31 AM5/5/09
to Railo
Just in case someone is looking for a bare-bones init.d script that will work on any Linux distro and will still force Tomcat to stop, here it is (it just leverages the "-force" option offered by the catalina.sh script, which executes a "kill" of the process right after the stop):


NAME=tomcat6
DESC="Tomcat servlet engine"
TOMCAT_HOME=/opt/$NAME
PIDFILE=$TOMCAT_HOME/work/$NAME.pid
DAEMON=$TOMCAT_HOME/bin/catalina.sh
TOMCAT_USER=$NAME
# This allows the Tomcat startup script to create a PID file:
export CATALINA_PID="$PIDFILE"

case "$1" in
    start)
        echo "Starting $DESC" "$NAME"
        su $TOMCAT_USER $DAEMON start
    ;;
    stop)
        echo "Stopping $DESC" "$NAME"
        su $TOMCAT_USER $DAEMON stop -force
        rm -f $PIDFILE
    ;;
    restart|force-reload)
        $0 stop
        sleep 3
        $0 start
    ;;
    *)
        echo "Usage: $0 {start|stop|restart|force-reload|status}"

        exit 1
    ;;
esac

exit 0

Best,
Jamie

Barney Boisvert

unread,
May 5, 2009, 12:10:35 PM5/5/09
to ra...@googlegroups.com
Good find, Jamie! Way easier that my suggestion. Gonna go tweak my
script right now.

Terry Schmitt

unread,
May 5, 2009, 1:09:31 PM5/5/09
to Railo
I've used the -force switch in the past, but that probably isn't the
cleanest method to shutdown Tomcat.
Anyone have an idea what all these hanging processes are doing, if
anything? What is the impact of using "kill"? I'll bet it's a small
risk, but I personally hate using workarounds... Maybe Apache put the -
force in there for a reason?? Knowing that they have an issue?

T
> bboisv...@gmail.comhttp://www.barneyb.com/

Jamie Krug

unread,
May 5, 2009, 1:30:39 PM5/5/09
to ra...@googlegroups.com
On Tue, May 5, 2009 at 1:09 PM, Terry Schmitt <terry....@gmail.com> wrote:
>
> I've used the -force switch in the past, but that probably isn't the
> cleanest method to shutdown Tomcat.
> Anyone have an idea what all these hanging processes are doing, if
> anything? What is the impact of using "kill"? I'll bet it's a small
> risk, but I personally hate using workarounds... Maybe Apache put the -
> force in there for a reason?? Knowing that they have an issue?

Yes, a kill does not seem like the cleanest solution to stop the
Tomcat service, but I see no alternatives. In searching for
experiences with this problem, there was a lot of chatter about use of
Quartz Scheduler in one of the apps deployed under Tomcat, but nothing
definitive. And yes, it is quite curious that they have the -force
(kill) option built into the script that ships with the binary distro,
so I have a feeling this is not an uncommon issue. The Ubuntu init.d
script that I posted will sleep for a few seconds and then check to
see if the process is still running after a stop call, then it will
only kill it if the stop didn't take care of it. That said, this seems
to be every time, so I either need to kill it, reboot or allow unused
running processes to run wild with my RAM -- kill is the best option
in this trio!

Best,
Jamie

Terry Schmitt

unread,
May 10, 2009, 3:51:20 PM5/10/09
to Railo
I've circled back around to trying Tomcat again. The one thing that
stands out is that this problem appears to be application specific.
The most logical thing that I have read is that an application creates
a non-deamon thread and does not shut down that process when Tomcat
shuts down.

To test this I took my basic Tomcat install. It starts and stops
cleanly using my init.d script.
I then deploy the railo.war file. I click around the Server/Web Admin
a little then stop Tomcat. No surprise, I end up with a bunch of
tomcat threads that won't die.
I then issue "kill -QUIT <pid>" to dump the active threads. The only
non-deamon threads are listed below and they are all Railo threads.
I then undeploy railo and tomcat, once again, starts and stops
cleanly.

So... The question is... Is this a Railo problem or a Tomcat problem?
I've read about bugs for other applications that have been fixed to
correct this behavior, so it would seem that maybe Railo is not
handling the shutdown of these threads correctly?

It definitely seems worth investigating by the Railo team, as Tomcat
will obviously be a common engine for Railo apps.

Thanks,
Terry

*************************************************************************************************************
"Thread-8" prio=10 tid=0x0821dc00 nid=0x124d waiting on condition
[0xb5109000..0xb510a040]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at railo.commons.io.SystemUtil.sleep(SystemUtil.java:338)
at railo.runtime.schedule.ScheduleThread.run
(ScheduleThread.java:22)


"Thread-6" prio=10 tid=0x08224000 nid=0x1249 waiting on condition
[0xb51d4000..0xb51d4140]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at railo.commons.io.SystemUtil.sleep(SystemUtil.java:338)
at railo.runtime.schedule.ScheduleThread.run
(ScheduleThread.java:22)


"Thread-4" prio=10 tid=0x0844f000 nid=0x1247 waiting on condition
[0xb5281000..0xb5281e40]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at railo.commons.io.SystemUtil.sleep(SystemUtil.java:338)
at railo.runtime.schedule.ScheduleThread.run
(ScheduleThread.java:22)


"Thread-2" prio=10 tid=0x084c8c00 nid=0x1245 waiting on condition
[0xb53e2000..0xb53e2f40]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at railo.commons.io.SystemUtil.sleep(SystemUtil.java:338)
at railo.runtime.schedule.ScheduleThread.run
(ScheduleThread.java:22)

Gert Franz

unread,
May 11, 2009, 3:29:58 AM5/11/09
to ra...@googlegroups.com
That's true... we should and will investigate that. Just for the record:
What threads are still surviving? Any particular ones? Can you list them
here? Or even better, pls open up a ticket in JIRA!

Thanks a lot.

Gert

-----Ursprüngliche Nachricht-----
Von: ra...@googlegroups.com [mailto:ra...@googlegroups.com] Im Auftrag von
Terry Schmitt
Gesendet: Sonntag, 10. Mai 2009 21:51
An: Railo
Betreff: [railo] Re: Tomcat 6 processes won't die when stopped, with Railo
3.1?

Terry Schmitt

unread,
May 11, 2009, 11:47:04 AM5/11/09
to Railo
Jira RAILO-230 created.

Jamie Krug

unread,
Oct 27, 2009, 11:22:56 AM10/27/09
to Railo
DOH! Todd Rafferty just tried this script and received a "su: invalid option -- o" error when attempting to shut down Tomcat with this script ("/etc/init.d/tomcat6 stop" as root). I obviously whipped this up rather quickly and didn't test, so my apologies. Here's a tested (on Ubuntu) script that should work on any Linux distro (I was missing the -c option in each of the su command lines, and quotes around the command to be executed)...


NAME=tomcat6
DESC="Tomcat servlet engine"
TOMCAT_HOME=/opt/$NAME
PIDFILE=$TOMCAT_HOME/work/$NAME.pid
DAEMON=$TOMCAT_HOME/bin/catalina.sh
TOMCAT_USER=$NAME
# This allows the Tomcat startup script to create a PID file:
export CATALINA_PID="$PIDFILE"

case "$1" in
    start)
        echo "Starting $DESC" "$NAME"

        su $TOMCAT_USER -c "$DAEMON start"

    ;;
    stop)
        echo "Stopping $DESC" "$NAME"
        su $TOMCAT_USER -c "$DAEMON stop -force"
        rm -f $PIDFILE
    ;;
    restart)

        $0 stop
        sleep 3
        $0 start
    ;;
    *)
        echo "Usage: $0 {start|stop|restart}"

        exit 1
    ;;
esac

exit 0

I should note that this script assumes you have a Tomcat distro folder (or symlink) at /opt/tomcat6 and a "tomcat6" user that has write permissions to relevant Tomcat directories that require it. Starting with root owner/group for /opt/tomcat6, here's a string of commands that will make everything nice on Ubuntu (on other distros just get rid of each "sudo" and be sure you execute this command as root):

sudo groupadd tomcat6 ; \
    sudo useradd -g tomcat6 tomcat6 ; \
    sudo chmod 644 /opt/tomcat6/conf/* ; \
    sudo chgrp tomcat6 /opt/tomcat6/logs/ ; \
    sudo chmod g+w /opt/tomcat6/logs/ ; \
    sudo chgrp -R tomcat6 /opt/tomcat6/temp/ ; \
    sudo chmod -R g+w /opt/tomcat6/temp/ ; \
    sudo chgrp tomcat6 /opt/tomcat6/work/ ; \
    sudo chmod g+w /opt/tomcat6/work/

Best,
Jamie
Reply all
Reply to author
Forward
0 new messages