Re: running Tomcat as a service/daemon on Linux

2002-07-28 Thread David Goodenough

On Sunday 28 July 2002 05:53, you wrote:
 I don't know what your OS is, but I installed via RPM and I have a
 script in /etc/rc.d/init.d named tomcat4.  No, it's not as handy as
 service tomcat4 start, but it works :-)  I typically wind up doing
From what I understand service is a script which runs things out of
init.d (where ever it is on your machine).
 something like !?4 rest? anyway :-P (which grabs the last restart out of
 my history and executes it).  That's even shorter than service tomcat4
 restart :-D

 Chris Ruegger wrote:
 Is it possible to set up Tomcat on a Linux
 machine such that I can start it/stop with the
 service command, i.e.
 
 service tomcat start
 service tomcat stop
 
 If so, how would one do this? Do most people set up
 Tomcat as a daemon on Unix machines? If so,
 tips on how this is done appreciated!!

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: running Tomcat as a service/daemon on Linux

2002-07-28 Thread Tore Skogly

søndag 28. juli 2002, 06:53, wrote Eddie Bush:
 I don't know what your OS is, but I installed via RPM and I have a
 script in /etc/rc.d/init.d named tomcat4.  No, it's not as handy as
 service tomcat4 start, but it works :-)  I typically wind up doing
 something like !?4 rest? anyway :-P (which grabs the last restart out of
 my history and executes it).  That's even shorter than service tomcat4
 restart :-D


and there you have your service.
Try service tomcat4 start and see what happens.
If you use sysv-init you can edit what runlevel you want tomcat to start.

-- 
regards,
Tore Skogly

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: running Tomcat as a service/daemon on Linux

2002-07-27 Thread David Goodenough

On Saturday 27 July 2002 18:38, you wrote:
 Is it possible to set up Tomcat on a Linux
 machine such that I can start it/stop with the
 service command, i.e.

 service tomcat start
 service tomcat stop

 If so, how would one do this? Do most people set up
 Tomcat as a daemon on Unix machines? If so,
 tips on how this is done appreciated!!

all service does it to run a script found in /etc/init.d
(or /etc/rc.d/init.d on older systems).  So write a script
that starts and stops tomcat.

The Debian tomcat4 package comes with the following script
so it might need a bit of modification for your environment:-

f#! /bin/sh -e
#
# /etc/init.d/tomcat4 -- startup script for the Tomcat 4.0 servlet engine
#
# Written by Miquel van Smoorenburg [EMAIL PROTECTED].
# Modified for Debian GNU/Linux by Ian Murdock [EMAIL PROTECTED].
# Modified for Tomcat by Stefan Gybas [EMAIL PROTECTED].

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=tomcat4
DESC=Tomcat 4.0 servlet engine
DAEMON=/usr/bin/$NAME
CATALINA_HOME=/usr/share/$NAME

# The following variables can be overwritten in /etc/default/tomcat4

# Run Tomcat 4.0 as this user ID (default: tomcat4)
# Set this to an empty string to prevent Tomcat from starting automatically
TOMCAT4_USER=tomcat4

# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
# defined in /etc/default/tomcat4)
JDK_DIRS=/usr/lib/j2se/1.3 /usr/lib/j2sdk1.3

# Arguments to pass to the Java virtual machine (JVM)
CATALINA_OPTS=

# Use the Java security manager? (yes/no)
TOMCAT4_SECURITY=yes

# End of variables that can be overwritten in /etc/default/tomcat4

# overwrite settings from default file
if [ -f /etc/default/tomcat4 ]; then
. /etc/default/tomcat4
fi

test -f $DAEMON || exit 0

# Look for the right JVM to use
for jdir in $JDK_DIRS; do
if [ -d $jdir -a -z ${JAVA_HOME} ]; then
JAVA_HOME=$jdir
fi
done
export JAVA_HOME
export CATALINA_OPTS

# Define other required variables
PIDFILE=/var/run/$NAME.pid
LOGDIR=$CATALINA_HOME/logs
WEBAPPDIR=$CATALINA_HOME/webapps
STARTUP_OPTS=
if [ $TOMCAT4_SECURITY = yes ]; then
STARTUP_OPTS=-security
fi

case $1 in
  start)
if [ -z $TOMCAT4_USER ]; then
echo Not starting $DESC as configured (TOMCAT4_USER is empty in
echo /etc/default/tomcat4).
exit 0
fi
if [ -z $JAVA_HOME ]; then
echo Could not start $DESC because no Java Development Kit
echo (JDK) was found. Please download and install JDK 1.3 or higher and 
set
echo JAVA_HOME in /etc/default/tomcat4 to the JDK's installation 
directory.
exit 0
fi

echo -n Starting $DESC using Java from $JAVA_HOME: 

# Remove dangling webapp symlinks
for webapp in $WEBAPPDIR/*; do
if [ $webapp != $WEBAPPDIR/* -a ! -e $webapp ]; then
echo Removing obsolete webapp $webapp $LOGDIR/catalina.out
rm $webapp  $LOGDIR/catalina.out 21 || true
fi
done

# Symlink new webapps from /usr/share/java/webapps
for webapp in /usr/share/java/webapps/*; do
if [ -e $webapp -a ! -e $WEBAPPDIR/`basename $webapp` \
-a ! -e $WEBAPPDIR/`basename $webapp .war` ]; then
echo Symlinking new webapp $webapp $LOGDIR/catalina.out
ln -s $webapp $WEBAPPDIR || true
fi
done

# Create catalina.policy (for the security manager)
rm -f /var/lib/tomcat4/catalina.policy
cat /etc/tomcat4/policy.d/*.policy /var/lib/tomcat4/catalina.policy

mkdir -p $CATALINA_HOME/work/_temp
touch $PIDFILE $LOGDIR/catalina.out || true
chown --dereference $TOMCAT4_USER $PIDFILE $LOGDIR \
$LOGDIR/catalina.out $CATALINA_HOME/work \
$CATALINA_HOME/temp || true
if start-stop-daemon --test --start --pidfile $PIDFILE \
--user $TOMCAT4_USER --startas $DAEMON /dev/null; then
# -p preserves the environment (for $JAVA_HOME etc.)
su -p $TOMCAT4_USER -c \$DAEMON\ start $STARTUP_OPTS \
$LOGDIR/catalina.out 21
echo $NAME.
else
echo (already running).
fi
;;
  stop)
echo -n Stopping $DESC: 
if start-stop-daemon --test --start --pidfile $PIDFILE \
--user $TOMCAT4_USER --startas $DAEMON /dev/null; then
echo (not running).
else
su -p $TOMCAT4_USER -c \$DAEMON\ stop /dev/null 21 || true
# Fallback to kill the JVM process in case stopping did not work
sleep 1
start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE \
--user $TOMCAT4_USER
rm -f $PIDFILE
echo $NAME.
fi
;;
#  reload)
#   echo -n Reloading $DESC configuration files... 

Re: running Tomcat as a service/daemon on Linux

2002-07-27 Thread John Gentilin

Copy the file TOMCAT/bin/tomcat.sh to the /etc/init.d directory.
the make the proper links to the run level directories. If you have
redhat, use the chkconfiig command after you copy the file.
i.e.

# to see what's running
chkconfig --list

#to turn on Tomcat
chkconfig -level 3 tomcat on

Tomcat does not use the daemon / service command to track
PID's it will issue a socket command when stopping.


Regards
John G


Chris Ruegger wrote:

 Is it possible to set up Tomcat on a Linux
 machine such that I can start it/stop with the
 service command, i.e.

 service tomcat start
 service tomcat stop

 If so, how would one do this? Do most people set up
 Tomcat as a daemon on Unix machines? If so,
 tips on how this is done appreciated!!



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: running Tomcat as a service/daemon on Linux

2002-07-27 Thread Eddie Bush

I don't know what your OS is, but I installed via RPM and I have a 
script in /etc/rc.d/init.d named tomcat4.  No, it's not as handy as 
service tomcat4 start, but it works :-)  I typically wind up doing 
something like !?4 rest? anyway :-P (which grabs the last restart out of 
my history and executes it).  That's even shorter than service tomcat4 
restart :-D

Chris Ruegger wrote:

Is it possible to set up Tomcat on a Linux
machine such that I can start it/stop with the 
service command, i.e.

service tomcat start
service tomcat stop

If so, how would one do this? Do most people set up
Tomcat as a daemon on Unix machines? If so,
tips on how this is done appreciated!!





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]