aboutsummaryrefslogtreecommitdiffstats
path: root/www/jakarta-tomcat41/files
diff options
context:
space:
mode:
authorznerd <znerd@FreeBSD.org>2002-03-30 22:51:12 +0800
committerznerd <znerd@FreeBSD.org>2002-03-30 22:51:12 +0800
commit385fdae0395f19ca6d45f8c847972c80d4caa3a8 (patch)
tree8010354820b48b8973a226cb2361ed0da7a0c46d /www/jakarta-tomcat41/files
parent28d17a453e8b5faa9ae240a41a437c72cb5d2315 (diff)
downloadfreebsd-ports-gnome-385fdae0395f19ca6d45f8c847972c80d4caa3a8.tar.gz
freebsd-ports-gnome-385fdae0395f19ca6d45f8c847972c80d4caa3a8.tar.zst
freebsd-ports-gnome-385fdae0395f19ca6d45f8c847972c80d4caa3a8.zip
Lot of changes: Using USE_JAVA infrastructure. Upgraded port
to 3.3.1. Using HTTP_PORT i.s.o. LISTEN_PORT. Using daemonctl.c i.s.o. tomcatctl shell script. Displaying steps i.s.o. commands being executed. Synced man page.
Diffstat (limited to 'www/jakarta-tomcat41/files')
-rw-r--r--www/jakarta-tomcat41/files/daemonctl.152
-rw-r--r--www/jakarta-tomcat41/files/daemonctl.c379
-rw-r--r--www/jakarta-tomcat41/files/jakarta-tomcat.sh18
-rw-r--r--www/jakarta-tomcat41/files/patch-aa45
-rw-r--r--www/jakarta-tomcat41/files/patch-ab19
-rw-r--r--www/jakarta-tomcat41/files/startup.sh18
-rw-r--r--www/jakarta-tomcat41/files/tomcatctl145
-rw-r--r--www/jakarta-tomcat41/files/tomcatctl.152
8 files changed, 473 insertions, 255 deletions
diff --git a/www/jakarta-tomcat41/files/daemonctl.1 b/www/jakarta-tomcat41/files/daemonctl.1
index 07514a35bcea..c0d332fda7d8 100644
--- a/www/jakarta-tomcat41/files/daemonctl.1
+++ b/www/jakarta-tomcat41/files/daemonctl.1
@@ -10,9 +10,9 @@
.Sh DESCRIPTION
The
.Nm
-shell script provides an interface to the %%APP_TITLE%% application server.
+program provides an interface to the %%APP_TITLE%% application server.
.Pp
-The script expects exactly one argument, either
+The program expects exactly one argument, either
.Ar start ,
.Ar restart
or
@@ -23,41 +23,53 @@ ignored.
.It Ar start
Start %%APP_TITLE%%, if it is not already running.
.It Ar restart
-Restart %%APP_TITLE%%. If it is already running, then it will be stopped and then
-started right after that. Otherwise it will just be started up.
+Restart %%APP_TITLE%%. If it is already running, then it will be stopped and
+then started right after that. Otherwise it will just be started up.
.It Ar stop
Stop %%APP_TITLE%%, if it is actually running.
.El
.Sh ERRORS
The following error conditions are detected. They will be checked in the
-specified order. In each case where an error message is printed, the name of
-the script
-.Em ( basename $0 )
-will be prepended.
+specified order. In each case an error message is printed with the name of the
+control program prepended.
.Pp
-If no argument is passed, or if an argument other than
+If no argument is passed, then a simple help message is printed and the
+program exists with error code 0.
+.Pp
+If at least one argument is passed, but it is different from
.Ar start ,
.Ar restart
or
.Ar stop
-is passed as the first argument, then a simple help message is printed and the
-script is exited with error code 64.
+then the help message is printed as well, and the program exits with error
+code 1.
.Pp
-Other than that, the following errors conditions are defined:
+The following errors conditions are defined:
.Bl -tag -width indent
-.It Em %%APP_TITLE%% home directory cannot be found
-Prints an error message and exits the script with error code 2.
-.It Em %%APP_TITLE%% script cannot be found
-Prints an error message and exits the script with error code 3.
-.It Em Java VM cannot be found
-Prints an error message and exits the script with error code 4.
+.It Em Illegal program argument (error code 1)
+.It Em PID file not found (error code 2)
+.It Em PID file too large (error code 3)
+.It Em PID file contains illegal character (error code 4)
+.It Em Kill of process failed (error code 5)
+.It Em %%APP_TITLE%% is already running (error code 6)
+.It Em %%APP_TITLE%% is not running (error code 7)
+.It Em Unable to chdir to the %%APP_TITLE%% home directory (error code 8)
+.It Em Unable to open the stdout log file (error code 9)
+.It Em Unable to open the stderr log file (error code 10)
+.It Em Unable to start %%APP_TITLE%% (error code 11)
.El
.Sh FILES
.Bl -tag -width -indent
-.It Pa %%PREFIX%%/etc/rc.d/%%STARTUP_ORDER%%.jakarta-tomcat.sh
+.It Pa %%PID_FILE%%
+The %%APP_TITLE%% PID file that is used to store the process ID of the
+currently running process in. It is emptied as soon as the server is stopped
+and filled with the process ID when it is started. It should never be writable
+for anyone but
+.Em www ,
+.It Pa %%STARTUP_SCRIPT%%
A script that starts the
.Nm
-script. It start %%APP_TITLE%% at startup time.
+program. It is used to start %%APP_TITLE%% at startup time.
.El
.Sh AUTHORS
.An Ernst de Haan Aq znerd@FreeBSD.org
diff --git a/www/jakarta-tomcat41/files/daemonctl.c b/www/jakarta-tomcat41/files/daemonctl.c
new file mode 100644
index 000000000000..23be5a7acffd
--- /dev/null
+++ b/www/jakarta-tomcat41/files/daemonctl.c
@@ -0,0 +1,379 @@
+/*
+ * -*- mode: Fundamental; tab-width: 4; -*-
+ * ex:ts=4
+ *
+ * Daemon control program.
+ *
+ * $FreeBSD: /tmp/pcvs/ports/www/jakarta-tomcat41/files/Attic/daemonctl.c,v 1.1 2002-03-30 14:51:12 znerd Exp $
+ */
+
+#include <assert.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <sys/errno.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+
+#define MAX_FILE_SIZE 32
+
+#define ERR_ILLEGAL_ARGUMENT 1
+#define ERR_PID_FILE_NOT_FOUND 2
+#define ERR_PID_FILE_TOO_LARGE 3
+#define ERR_PID_FILE_CONTAINS_ILLEGAL_CHAR 4
+#define ERR_KILL_FAILED 5
+#define ERR_ALREADY_RUNNING 6
+#define ERR_NOT_RUNNING 7
+#define ERR_CHDIR_TO_APP_HOME 8
+#define ERR_STDOUT_LOGFILE_OPEN 9
+#define ERR_STDERR_LOGFILE_OPEN 10
+#define ERR_FORK_FAILED 11
+
+#if defined JAVA_ARGS
+#define JAVA_ARGS_COMMA ,
+#else
+#define JAVA_ARGS
+#define JAVA_ARGS_COMMA
+#endif
+
+#if defined JAR_ARGS
+#define JAR_ARGS_COMMA ,
+#else
+#define JAR_ARGS
+#define JAR_ARGS_COMMA
+#endif
+
+#define private static
+
+private void printUsage(void);
+private int openPIDFile(void);
+private int readPID(int);
+private void writePID(int file, int pid);
+private void start(void);
+private void stop(void);
+private void restart(void);
+
+
+/**
+ * Main function. This function is called when this program is executed.
+ *
+ * @param argc
+ * the number of arguments plus one, so always greater than 0.
+ *
+ * @param argv
+ * the arguments in an array of character pointers, where the last argument
+ * element is followed by a NULL element.
+ */
+int main(int argc, char *argv[]) {
+
+ /* Declare variables, like all other good ANSI C programs do :) */
+ char *argument;
+
+ /* Parse the arguments */
+ if (argc < 2) {
+ printUsage();
+ return 0;
+ }
+
+ argument = argv[1];
+ if (strcmp("start", argument) == 0) {
+ start();
+ } else if (strcmp("stop", argument) == 0) {
+ stop();
+ } else if (strcmp("restart", argument) == 0) {
+ restart();
+ } else {
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Illegal argument \"%s\".\n", argument);
+ printUsage();
+ exit(ERR_ILLEGAL_ARGUMENT);
+ }
+
+ return 0;
+}
+
+
+/**
+ * Prints usage information to stdout.
+ */
+void printUsage(void) {
+ printf("Usage: %%CONTROL_SCRIPT_NAME%% [ start | stop | restart ]\n");
+}
+
+
+/**
+ * Attempts to open the PID file. If that file is successfully opened, then
+ * the file handle (an int) will be returned.
+ *
+ * @return
+ * the file handle.
+ */
+int openPIDFile(void) {
+
+ int file;
+
+ /* Attempt to open the PID file */
+ printf(">> Opening PID file (%%PID_FILE%%)...");
+ file = open("%%PID_FILE%%", O_RDWR);
+ if (file < 0) {
+ printf(" [ FAILED ]\n");
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%PID_FILE%% for reading and writing: ");
+ perror(NULL);
+ exit(ERR_PID_FILE_NOT_FOUND);
+ }
+ printf(" [ DONE ]\n");
+
+ return file;
+}
+
+
+/**
+ * Reads a PID from the specified file. The file is identified by a file
+ * handle.
+ *
+ * @param file
+ * the file handle.
+ *
+ * @return
+ * the PID, or -1 if the file was empty.
+ */
+int readPID(int file) {
+
+ char *buffer;
+ int hadNewline = 0;
+ unsigned int count;
+ unsigned int i;
+ int pid;
+
+ /* Read the PID file contents */
+ printf(">> Reading PID file...");
+ buffer = (char *) malloc((MAX_FILE_SIZE + 1) * sizeof(char));
+ count = read(file, buffer, MAX_FILE_SIZE + 1);
+ if (count > MAX_FILE_SIZE) {
+ printf(" [ FAILED ]\n");
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: The file %%PID_FILE%% contains more than %d bytes.\n", MAX_FILE_SIZE);
+ exit(ERR_PID_FILE_TOO_LARGE);
+ }
+
+ /* Convert the bytes to a number */
+ pid = 0;
+ for (i=0; i<count; i++) {
+ char c = buffer[i];
+ if (c >= '0' && c <= '9') {
+ char digit = c - '0';
+ pid *= 10;
+ pid += digit;
+ } else if (i == (count - 1) && c == '\n') {
+ /* XXX: Ignore a newline at the end of the file */
+ hadNewline = 1;
+ } else {
+ printf(" [ FAILED ]\n");
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: The file %%PID_FILE%% contains an illegal character (%d) at position %d.\n", c, i);
+ exit(ERR_PID_FILE_CONTAINS_ILLEGAL_CHAR);
+ }
+ }
+ printf(" [ DONE ]\n");
+
+ if (count == 0 || (count == 1 && hadNewline == 1)) {
+ return -1;
+ }
+
+ return pid;
+}
+
+
+/**
+ * Writes a process ID to the specified file. The file is identified by a file
+ * handle.
+ *
+ * @param file
+ * the file handle, always greater than 0.
+ *
+ * @param pid
+ * the PID to store, always greater than 0.
+ */
+void writePID(int file, int pid) {
+
+ char *buffer;
+ int nbytes;
+
+ /* Check preconditions */
+ assert(file > 0);
+ assert(pid > 0);
+
+ printf(">> Writing PID file...");
+
+ lseek(file, 0, SEEK_SET);
+ ftruncate(file, 0);
+ nbytes = asprintf(&buffer, "%d\n", pid);
+ write(file, buffer, nbytes);
+ printf(" [ DONE ]\n");
+}
+
+
+/**
+ * Kills the process identified by the specified ID.
+ *
+ * @param pid
+ * the process id, greater than 0.
+ */
+void killProcess(int pid) {
+
+ int result;
+
+ assert(pid > 0);
+
+ printf(">> Killing process %d...", pid);
+ result = kill(pid, SIGTERM);
+ if (result < 0) {
+ printf(" [ FAILED ]\n");
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to kill process %d: ", pid);
+ perror(NULL);
+ exit(ERR_KILL_FAILED);
+ }
+
+ printf(" [ DONE ]\n");
+}
+
+
+/**
+ * Starts the daemon.
+ */
+void start(void) {
+
+ int file;
+ int pid;
+ int result;
+ int stdoutLogFile;
+ int stderrLogFile;
+
+ /* Open and read the PID file */
+ file = openPIDFile();
+ pid = readPID(file);
+
+ printf(">> Checking that %%APP_TITLE%% is not already running...");
+ if (pid != -1) {
+
+ /* Check if the process actually exists */
+ result = kill(pid, 0);
+ if (result == 0 || errno != ESRCH) {
+ printf(" [ FAILED ]\n");
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% is already running, PID is %d.\n", pid);
+ exit(ERR_ALREADY_RUNNING);
+ }
+ }
+
+ printf(" [ DONE ]\n");
+
+ /* XXX: printf(">> Checking for Java VM..."); */
+
+ printf(">> Starting %%APP_TITLE%%...");
+
+ /* Change directory */
+ result = chdir("%%APP_HOME%%");
+ if (result < 0) {
+ printf(" [ FAILED ]\n");
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to access directory %%APP_HOME%%: ");
+ perror(NULL);
+ exit(ERR_CHDIR_TO_APP_HOME);
+ }
+
+ /* Open the stdout log file */
+ stdoutLogFile = open("%%STDOUT_LOG%%", O_WRONLY);
+ if (stdoutLogFile < 0) {
+ printf(" [ FAILED ]\n");
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDOUT_LOG%% for writing: ");
+ perror(NULL);
+ exit(ERR_STDOUT_LOGFILE_OPEN);
+ }
+ lseek(stdoutLogFile, 0, SEEK_END);
+
+ /* Open the stderr log file */
+ stderrLogFile = open("%%STDERR_LOG%%", O_WRONLY);
+ if (stderrLogFile < 0) {
+ printf(" [ FAILED ]\n");
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to open %%STDERR_LOG%% for writing: ");
+ perror(NULL);
+ exit(ERR_STDERR_LOGFILE_OPEN);
+ }
+ lseek(stderrLogFile, 0, SEEK_END);
+
+ /* Split this process in two */
+ pid = fork();
+ if (pid == -1) {
+ printf(" [ FAILED ]\n");
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to fork: ");
+ perror(NULL);
+ exit(ERR_FORK_FAILED);
+ }
+
+ if (pid == 0) {
+
+ /* Redirect stdout to log file */
+ dup2(stdoutLogFile, STDOUT_FILENO);
+
+ /* Redirect stderr to log file */
+ dup2(stderrLogFile, STDERR_FILENO);
+
+ /* TODO: Support redirection of both stdout and stderr to the same
+ file using pipe(2) */
+
+ /* Execute the command */
+ execl("%%JAVA_HOME%%/%%JAVA_CMD%%", "%%JAVA_HOME%%/%%JAVA_CMD%%", "-jar", JAVA_ARGS JAVA_ARGS_COMMA "%%JAR_FILE%%", JAR_ARGS JAR_ARGS_COMMA NULL);
+
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to start %%APP_TITLE%% as '%%JAVA_HOME%%/%%JAVA_CMD%% -jar %%JAR_FILE%%' in %%APP_HOME%%: ");
+ perror(NULL);
+ } else {
+ printf(" [ DONE ]\n");
+ writePID(file, pid);
+ }
+}
+
+/**
+ * Stops the daemon.
+ */
+void stop(void) {
+
+ int file;
+ int pid;
+
+ /* Open and read the PID file */
+ file = openPIDFile();
+ pid = readPID(file);
+
+ printf(">> Checking that %%APP_TITLE%% is running...");
+
+ /* If there is a PID, see if the process still exists */
+ if (pid != -1) {
+ int result = kill(pid, 0);
+ if (result != 0 && errno == ESRCH) {
+ ftruncate(file, 0);
+ pid = -1;
+ }
+ }
+
+ /* If there is no running process, produce an error */
+ if (pid == -1) {
+ printf(" [ FAILED ]\n");
+ fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: %%APP_TITLE%% is currently not running.\n");
+ exit(ERR_NOT_RUNNING);
+ }
+
+ printf(" [ DONE ]\n");
+
+ killProcess(pid);
+
+ printf(">> Clearing PID file...");
+ ftruncate(file, 0);
+ printf(" [ DONE ]\n");
+}
+
+
+void restart(void) {
+ stop();
+ start();
+}
diff --git a/www/jakarta-tomcat41/files/jakarta-tomcat.sh b/www/jakarta-tomcat41/files/jakarta-tomcat.sh
index cbd3e16f99b1..b27dea9f7de5 100644
--- a/www/jakarta-tomcat41/files/jakarta-tomcat.sh
+++ b/www/jakarta-tomcat41/files/jakarta-tomcat.sh
@@ -1,15 +1,27 @@
#!/bin/sh
+# -*- mode: Fundamental; tab-width: 4; -*-
+# ex:ts=4
+#
+# %%APP_TITLE%% startup script.
+#
+# $FreeBSD$
+#
+
# Set some variables
-USER_NAME=%%USER_NAME%%
MYSELF=`basename $0`
case "$1" in
start)
- su -f -m ${USER_NAME} -c "exec %%CONTROL_SCRIPT%% start" && echo -n ' %%APP_SHORTNAME%%'
+ truncate -s 0 %%PID_FILE%%
+ chown %%USER%%:%%GROUP%% %%PID_FILE%%
+ chmod 600 %%PID_FILE%%
+ su -f -m %%USER%% -c "exec %%CONTROL_SCRIPT%% start > /dev/null" && echo -n ' %%APP_SHORTNAME%%'
;;
stop)
- su -f -m ${USER_NAME} -c "exec %%CONTROL_SCRIPT%% stop" && echo -n ' %%APP_SHORTNAME%%'
+ chown %%USER%%:%%GROUP%% %%PID_FILE%%
+ chmod 600 %%PID_FILE%%
+ su -f -m %%USER%% -c "exec %%CONTROL_SCRIPT%% stop > /dev/null" && echo -n ' %%APP_SHORTNAME%%'
;;
*)
echo ""
diff --git a/www/jakarta-tomcat41/files/patch-aa b/www/jakarta-tomcat41/files/patch-aa
deleted file mode 100644
index eb725993cf38..000000000000
--- a/www/jakarta-tomcat41/files/patch-aa
+++ /dev/null
@@ -1,45 +0,0 @@
---- conf/workers.properties.orig Tue Dec 12 22:36:26 2000
-+++ conf/workers.properties Sun May 20 16:06:33 2001
-@@ -40,20 +40,20 @@
- # installed tomcat. This is where you have your conf, webapps and lib
- # directories.
- #
--workers.tomcat_home=c:\jakarta-tomcat
-+workers.tomcat_home=%%TOMCAT_HOME%%
-
- #
- # workers.java_home should point to your Java installation. Normally
- # you should have a bin and lib directories beneath it.
- #
--workers.java_home=c:\jdk1.2.2
-+workers.java_home=%%JAVA_HOME%%
-
- #
- # You should configure your environment slash... ps=\ on NT and / on UNIX
- # and maybe something different elsewhere.
- #
--ps=\
--# ps=/
-+#ps=\
-+ps=/
-
- #
- #------ ADVANCED MODE ------------------------------------------------
-@@ -166,7 +166,7 @@
- #
- # Javac as available from Java2SE
- #
--worker.inprocess.class_path=$(workers.java_home)$(ps)lib$(ps)tools.jar
-+#worker.inprocess.class_path=$(workers.java_home)$(ps)lib$(ps)tools.jar
-
- #
- # Setting the command line for tomcat
-@@ -182,7 +182,7 @@
- #
- # This is for Java2
- #
--worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)jvm.dll
-+#worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)jvm.dll
-
- #
- # And this is for jdk1.1.X
diff --git a/www/jakarta-tomcat41/files/patch-ab b/www/jakarta-tomcat41/files/patch-ab
deleted file mode 100644
index 9493d0cbee73..000000000000
--- a/www/jakarta-tomcat41/files/patch-ab
+++ /dev/null
@@ -1,19 +0,0 @@
---- conf/server.xml.orig Tue Jul 17 18:57:46 2001
-+++ conf/server.xml Thu Jan 24 14:32:56 2002
-@@ -68,6 +68,7 @@
- -->
- <Logger name="tc_log"
- verbosityLevel = "INFORMATION"
-+ path="logs/tomcat.log"
- />
-
- <Logger name="servlet_log"
-@@ -223,7 +224,7 @@
- <Parameter name="handler"
- value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
- <Parameter name="port"
-- value="8080"/>
-+ value="%%LISTEN_PORT%%"/>
- </Connector>
-
- <!--
diff --git a/www/jakarta-tomcat41/files/startup.sh b/www/jakarta-tomcat41/files/startup.sh
index cbd3e16f99b1..b27dea9f7de5 100644
--- a/www/jakarta-tomcat41/files/startup.sh
+++ b/www/jakarta-tomcat41/files/startup.sh
@@ -1,15 +1,27 @@
#!/bin/sh
+# -*- mode: Fundamental; tab-width: 4; -*-
+# ex:ts=4
+#
+# %%APP_TITLE%% startup script.
+#
+# $FreeBSD$
+#
+
# Set some variables
-USER_NAME=%%USER_NAME%%
MYSELF=`basename $0`
case "$1" in
start)
- su -f -m ${USER_NAME} -c "exec %%CONTROL_SCRIPT%% start" && echo -n ' %%APP_SHORTNAME%%'
+ truncate -s 0 %%PID_FILE%%
+ chown %%USER%%:%%GROUP%% %%PID_FILE%%
+ chmod 600 %%PID_FILE%%
+ su -f -m %%USER%% -c "exec %%CONTROL_SCRIPT%% start > /dev/null" && echo -n ' %%APP_SHORTNAME%%'
;;
stop)
- su -f -m ${USER_NAME} -c "exec %%CONTROL_SCRIPT%% stop" && echo -n ' %%APP_SHORTNAME%%'
+ chown %%USER%%:%%GROUP%% %%PID_FILE%%
+ chmod 600 %%PID_FILE%%
+ su -f -m %%USER%% -c "exec %%CONTROL_SCRIPT%% stop > /dev/null" && echo -n ' %%APP_SHORTNAME%%'
;;
*)
echo ""
diff --git a/www/jakarta-tomcat41/files/tomcatctl b/www/jakarta-tomcat41/files/tomcatctl
deleted file mode 100644
index 9992f023380b..000000000000
--- a/www/jakarta-tomcat41/files/tomcatctl
+++ /dev/null
@@ -1,145 +0,0 @@
-#!/bin/sh
-
-# Set some variables
-APP_HOME=%%APP_HOME%%
-STDOUT_LOG=%%STDOUT_LOG%%
-STDERR_LOG=%%STDERR_LOG%%
-JAR_FILE=${APP_HOME}/lib/webserver.jar
-MYSELF=`basename $0`
-
-# Set the CLASSPATH
-unset CLASSPATH
-for i in ${APP_HOME}/lib/* ; do
- if [ "$CLASSPATH" != "" ]; then
- CLASSPATH=${CLASSPATH}:$i
- else
- CLASSPATH=$i
- fi
-done
-
-# Check if the JAVA_HOME directory is defined, otherwise set it to the
-# fallback default
-if [ "${JAVA_HOME}a" = "a" ]; then
- JAVA_HOME=%%JAVA_HOME%%
-fi
-if [ -f ${JAVA_HOME}/lib/tools.jar ] ; then
- CLASSPATH=${CLASSPATH}:${JAVA_HOME}/lib/tools.jar
-fi
-JAVA_CMD=${JAVA_HOME}/bin/java
-
-
-##############################################################################
-# Function that shows an error message
-#
-# This function is called by the 'checks' function
-#
-# Parameters:
-# 1: The message to be displayed.
-
-error() {
- echo -n "%%APP_SHORTNAME%%: ERROR: "
- echo $1
-}
-
-
-##############################################################################
-# Function that performs all checks necessary for starting or stopping the
-# application.
-#
-# This function is called by the 'start' and 'stop' functions
-#
-# This function expects no parameters
-
-checks() {
- # Make sure the application directory does exist
- if [ ! -d ${APP_HOME} ]; then
- error "Unable to find %%APP_TITLE%% home directory at ${APP_HOME}."
- exit 2
- fi
-
- # Make sure the application JAR file exists
- if [ ! -r ${JAR_FILE} ]; then
- error "Unable to find %%APP_TITLE%% JAR file at ${JAR_FILE}."
- exit 3
- fi
-
- # Make sure the Java VM can be found
- if [ ! -x ${JAVA_CMD} ]; then
- error "Unable to find Java VM at ${JAVA_HOME}."
- exit 4
- fi
-}
-
-
-##############################################################################
-# Functions that calls the application with the specified parameter
-#
-# Parameters:
-# 1: The argument to pass to the application (optional)
-
-app() {
- (cd ${APP_HOME} && ${JAVA_CMD} -cp ${CLASSPATH} -Dtomcat.home=${APP_HOME} org.apache.tomcat.startup.Tomcat $1 &) >> ${STDOUT_LOG} 2>> ${STDERR_LOG}
-}
-
-
-##############################################################################
-# Function that starts the application
-#
-# This function is called from the main function
-#
-# This function expects no parameters
-
-start() {
- # Perform the checks
- checks
-
- # Stop the application
- app
-}
-
-
-##############################################################################
-# Function that stops the application
-#
-# This function is called from the main function
-#
-# This function expects no parameters
-
-stop() {
- # Perform the checks
- checks
-
- # Stop the application
- app -stop
-}
-
-
-##############################################################################
-# Main function. This function calls the 'start' and 'stop' functions.
-#
-# Parameters:
-# 1: The argument to this shell script
-
-main() {
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- *)
- echo "Usage: ${MYSELF} { start | stop | restart }"
- exit 64
- ;;
- esac
-}
-
-
-# Call the main function and exit
-main $1
-exit 0
diff --git a/www/jakarta-tomcat41/files/tomcatctl.1 b/www/jakarta-tomcat41/files/tomcatctl.1
index 07514a35bcea..c0d332fda7d8 100644
--- a/www/jakarta-tomcat41/files/tomcatctl.1
+++ b/www/jakarta-tomcat41/files/tomcatctl.1
@@ -10,9 +10,9 @@
.Sh DESCRIPTION
The
.Nm
-shell script provides an interface to the %%APP_TITLE%% application server.
+program provides an interface to the %%APP_TITLE%% application server.
.Pp
-The script expects exactly one argument, either
+The program expects exactly one argument, either
.Ar start ,
.Ar restart
or
@@ -23,41 +23,53 @@ ignored.
.It Ar start
Start %%APP_TITLE%%, if it is not already running.
.It Ar restart
-Restart %%APP_TITLE%%. If it is already running, then it will be stopped and then
-started right after that. Otherwise it will just be started up.
+Restart %%APP_TITLE%%. If it is already running, then it will be stopped and
+then started right after that. Otherwise it will just be started up.
.It Ar stop
Stop %%APP_TITLE%%, if it is actually running.
.El
.Sh ERRORS
The following error conditions are detected. They will be checked in the
-specified order. In each case where an error message is printed, the name of
-the script
-.Em ( basename $0 )
-will be prepended.
+specified order. In each case an error message is printed with the name of the
+control program prepended.
.Pp
-If no argument is passed, or if an argument other than
+If no argument is passed, then a simple help message is printed and the
+program exists with error code 0.
+.Pp
+If at least one argument is passed, but it is different from
.Ar start ,
.Ar restart
or
.Ar stop
-is passed as the first argument, then a simple help message is printed and the
-script is exited with error code 64.
+then the help message is printed as well, and the program exits with error
+code 1.
.Pp
-Other than that, the following errors conditions are defined:
+The following errors conditions are defined:
.Bl -tag -width indent
-.It Em %%APP_TITLE%% home directory cannot be found
-Prints an error message and exits the script with error code 2.
-.It Em %%APP_TITLE%% script cannot be found
-Prints an error message and exits the script with error code 3.
-.It Em Java VM cannot be found
-Prints an error message and exits the script with error code 4.
+.It Em Illegal program argument (error code 1)
+.It Em PID file not found (error code 2)
+.It Em PID file too large (error code 3)
+.It Em PID file contains illegal character (error code 4)
+.It Em Kill of process failed (error code 5)
+.It Em %%APP_TITLE%% is already running (error code 6)
+.It Em %%APP_TITLE%% is not running (error code 7)
+.It Em Unable to chdir to the %%APP_TITLE%% home directory (error code 8)
+.It Em Unable to open the stdout log file (error code 9)
+.It Em Unable to open the stderr log file (error code 10)
+.It Em Unable to start %%APP_TITLE%% (error code 11)
.El
.Sh FILES
.Bl -tag -width -indent
-.It Pa %%PREFIX%%/etc/rc.d/%%STARTUP_ORDER%%.jakarta-tomcat.sh
+.It Pa %%PID_FILE%%
+The %%APP_TITLE%% PID file that is used to store the process ID of the
+currently running process in. It is emptied as soon as the server is stopped
+and filled with the process ID when it is started. It should never be writable
+for anyone but
+.Em www ,
+.It Pa %%STARTUP_SCRIPT%%
A script that starts the
.Nm
-script. It start %%APP_TITLE%% at startup time.
+program. It is used to start %%APP_TITLE%% at startup time.
.El
.Sh AUTHORS
.An Ernst de Haan Aq znerd@FreeBSD.org