Specifying jdk for tomcat 4.1.18

Specifying jdk for tomcat 4.1.18

Post by Doug Polan » Fri, 21 Mar 2003 06:10:27



How do I specify a different jdk for tomcat?  I can't find it anywhere
in the conf/* files.  Seems that tomcat41ctl has /usr/local/jdk1.3.1
compiled into it.   Thought I might try tomcat with jdk1.4.1.

--
Regards,
Doug


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Milo Hys » Fri, 21 Mar 2003 06:16:17



>How do I specify a different jdk for tomcat?  I can't find it anywhere
>in the conf/* files.  Seems that tomcat41ctl has /usr/local/jdk1.3.1
>compiled into it.   Thought I might try tomcat with jdk1.4.1.

It determines the JDK from the JAVA_HOME environment variable.

--
Milo Hyson
*Life Labs


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Doug Polan » Fri, 21 Mar 2003 06:32:19


Milo Hyson said:


>>How do I specify a different jdk for tomcat?  I can't find it
>> anywhere in the conf/* files.  Seems that tomcat41ctl has
>> /usr/local/jdk1.3.1 compiled into it.   Thought I might try
>> tomcat with jdk1.4.1.

> It determines the JDK from the JAVA_HOME environment variable.

What happens when I (as root) don't have JAVA_HOME set when
/usr/local/etc/rc.d/020.jakarta-tomcat41.sh start is invoked?

What happens on system startup?

--
Regards,
Doug


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Milo Hys » Fri, 21 Mar 2003 06:53:14


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>
<blockquote type="cite"

  <pre wrap="">Milo Hyson said:
  </pre>
  <blockquote type="cite">

    </pre>
    <blockquote type="cite">
      <pre wrap="">How do I specify a different jdk for tomcat?  I can't find it
anywhere in the conf/* files.  Seems that tomcat41ctl has
/usr/local/jdk1.3.1 compiled into it.   Thought I might try
tomcat with jdk1.4.1.

      </pre>
    </blockquote>
    <pre wrap="">It determines the JDK from the JAVA_HOME environment variable.

    </pre>
  </blockquote>
  <pre wrap=""><!---->What happens when I (as root) don't have JAVA_HOME set when
/usr/local/etc/rc.d/020.jakarta-tomcat41.sh start is invoked?

What happens on system startup?

  </pre>
</blockquote>
Tomcat will not start unless JAVA_HOME is set -- it barfs with an
error. The startup script (in /usr/local/etc/rc.d) is probably setting
it for you. Look in there.<br>
<br>
<pre class="moz-signature" cols="72">--
Milo Hyson
*Life Labs
</pre>
</body>
</html>


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Doug Polan » Fri, 21 Mar 2003 11:01:43


Quote:>>> Doug asked:

>>>> How do I specify a different jdk for tomcat?  I can't find it
>>>> anywhere in the conf/* files.  Seems that tomcat41ctl has
>>>> /usr/local/jdk1.3.1 compiled into it.   Thought I might try
>>>> tomcat with jdk1.4.1.

>>> It determines the JDK from the JAVA_HOME environment variable.

>> What happens when I (as root) don't have JAVA_HOME set when
>> /usr/local/etc/rc.d/020.jakarta-tomcat41.sh start is invoked?

>> What happens on system startup?

> Tomcat will not start unless JAVA_HOME is set -- it barfs with an
> error. The startup script (in /usr/local/etc/rc.d) is probably
> setting it for you. Look in there.

Hmmm, when I start tomcat from
/usr/local/etc/rc.d/020.jakarta-tomcat41.sh
as root without JAVA_HOME set, tomcat starts just fine.  The
script does not set JAVA_HOME.  When I run strings on
/usr/local/bin/tomcat41ctl I see references to /usr/local/jdk1.3.1.
Unless I'm missing something, I think that this tomcat41ctl
port has the path to /usr/local/jdk1.3.1 compiled into the
binary and there is no way to path to a different jdk.

--
Regards,
Doug


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by leaf » Fri, 21 Mar 2003 11:07:27



> /usr/local/bin/tomcat41ctl I see references to /usr/local/jdk1.3.1.
> Unless I'm missing something, I think that this tomcat41ctl
> port has the path to /usr/local/jdk1.3.1 compiled into the
> binary and there is no way to path to a different jdk.

> --
> Regards,
> Doug

The same goes for jboss3ctl. If I want to switch to a different jdk, I have to recompile the whole thing(!). Is it possible to explicitly set JAVA_HOME when invoking the wrappers? Or by setting some configuration files for that?

Regards,
Jiawei

--
"Without the userland, the kernel is useless."
                                     --inspired by The Tao of Programming


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Doug Polan » Fri, 21 Mar 2003 11:21:49


leafy said:


>> /usr/local/bin/tomcat41ctl I see references to
>> /usr/local/jdk1.3.1. Unless I'm missing something, I think that
>> this tomcat41ctl port has the path to /usr/local/jdk1.3.1 compiled
>> into the binary and there is no way to path to a different jdk.

> The same goes for jboss3ctl. If I want to switch to a different
> jdk, I have to recompile the whole thing(!). Is it possible to
> explicitly set JAVA_HOME when invoking the wrappers? Or by setting
> some configuration files for that?

Curious.  I don't know the answer to your question.  How do you
recompile with a different jdk?  In the jakarta-tomcat41 Makefile it
echos $JAVA_HOME as /usr/local/jdk1.3.1 but I have no idea how it is
set.  I obviously don't know enough about the port Makefile
business.

Perhaps a knoweldgeable and kind soul can enlighten us why jdk1.3.1
is the only jdk for use in jboss3 and tomcat41.

--
Regards,
Doug


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Milo Hys » Fri, 21 Mar 2003 11:37:36


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>
<blockquote type="cite"

  <pre wrap="">leafy said:
  </pre>
  <blockquote type="cite">

    </pre>
    <blockquote type="cite">
      <pre wrap="">/usr/local/bin/tomcat41ctl I see references to
/usr/local/jdk1.3.1. Unless I'm missing something, I think that
this tomcat41ctl port has the path to /usr/local/jdk1.3.1 compiled
into the binary and there is no way to path to a different jdk.

      </pre>
    </blockquote>
    <pre wrap="">The same goes for jboss3ctl. If I want to switch to a different
jdk, I have to recompile the whole thing(!). Is it possible to
explicitly set JAVA_HOME when invoking the wrappers? Or by setting
some configuration files for that?

    </pre>
  </blockquote>
  <pre wrap=""><!---->Curious.  I don't know the answer to your question.  How do you
recompile with a different jdk?  In the jakarta-tomcat41 Makefile it
echos $JAVA_HOME as /usr/local/jdk1.3.1 but I have no idea how it is
set.  I obviously don't know enough about the port Makefile
business.

Perhaps a knoweldgeable and kind soul can enlighten us why jdk1.3.1
is the only jdk for use in jboss3 and tomcat41.
  </pre>
</blockquote>
<pre class="moz-signature" cols="72">I guess this is why I don't install Tomcat from ports. I just download the tarball and unzip it where I want it. Then I run the startup.sh script in the bin directory to kick Tomcat into gear. That script looks at the JAVA_HOME variable to determine which JVM to use.

--
Milo Hyson
*Life Labs
</pre>
</body>
</html>


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by leaf » Fri, 21 Mar 2003 11:53:45



> Curious.  I don't know the answer to your question.  How do you
> recompile with a different jdk?  In the jakarta-tomcat41 Makefile it
> echos $JAVA_HOME as /usr/local/jdk1.3.1 but I have no idea how it is
> set.  I obviously don't know enough about the port Makefile
> business.

> Perhaps a knoweldgeable and kind soul can enlighten us why jdk1.3.1
> is the only jdk for use in jboss3 and tomcat41.

> --
> Regards,
> Doug

I did submit a patch for bsd.java.mk which will make 1.4.1 jdk a dependency if it is the *only* jdk installed (I haven't come up with the multi-jdk case, but it looks really messy). With the patch, jboss and tomcat will pick up jdk14 as dependency and insert them into their respecitve wrappers.

Regards,

Jiawei

--
"Without the userland, the kernel is useless."
                                     --inspired by The Tao of Programming


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Brent Vern » Fri, 21 Mar 2003 13:12:14


[2003-03-19 20:21] Doug Poland said:
|
| leafy said:

| >> /usr/local/bin/tomcat41ctl I see references to
| >> /usr/local/jdk1.3.1. Unless I'm missing something, I think that
| >> this tomcat41ctl port has the path to /usr/local/jdk1.3.1 compiled
| >> into the binary and there is no way to path to a different jdk.
| >>
| > The same goes for jboss3ctl. If I want to switch to a different
| > jdk, I have to recompile the whole thing(!). Is it possible to
| > explicitly set JAVA_HOME when invoking the wrappers? Or by setting
| > some configuration files for that?
| >
| Curious.  I don't know the answer to your question.  How do you
| recompile with a different jdk?  In the jakarta-tomcat41 Makefile it
| echos $JAVA_HOME as /usr/local/jdk1.3.1 but I have no idea how it is
| set.  I obviously don't know enough about the port Makefile
| business.

| Perhaps a knoweldgeable and kind soul can enlighten us why jdk1.3.1
| is the only jdk for use in jboss3 and tomcat41.

I have a patch to the daemonctl.c source that causes it to use
JAVA_HOME, but this approach is not ideal, as there are other
difficulties aside from which java binary to use.

I'm taking over the jboss3 port (provided I find time to wrap
up the loose ends), and I've been thinking that a better solution
would be to have the daemonctl.c program call an appropriate
shell script instead of calling the java binary directly -- the
daemonctl.c program exists solely as a setuid/setgid wrapper
to startup the service in question.

I have begun to implement a daemonctl.c that uses a( set of xml)
config file(s) to control its actions.

sh$ ls -al /usr/local/bin/tomcat41ctl
lrwxr-xr-x   1 root  wheel        5 May 12  2002 tomcat41ctl -> jxdaemonctl
sh$ ls -1 /usr/local/etc/daemonctl.d/
tomcat41ctl.xml
jboss3ctl.xml
jboss-tomcat.xml

when called thru the tomcat41ctl symlink, the program will find the
tomcat41ctl.xml config file which looks like this.

<daemon>
  <user>www</user>
  <group>www</group>

  <setenv>
    <name>JAVA_HOME</name>
    <value>/usr/local/jdk1.4.1</value>
  </setenv>
  <setenv>
    <name>CATALINA_TMPDIR</name>
    <value>/var/tmp/tomcat41</value>
  </setenv>

  <chdir>/</chdir>

  <logs>
   <stdout>/usr/local/jakarta-tomcat4.1/logs/stdout.log</stdout>
   <stderr>/usr/local/jakarta-tomcat4.1/logs/stderr.log</stderr>
  </logs>

  <actions>
    <start>
      <exec>/usr/local/jakarta-tomcat4.1/bin/catalina.sh</exec>
      <arg>run</arg>
      <arg>-security</arg>
    </start>
    <stop>
      <exec fork="false">/usr/local/jakarta-tomcat4.1/bin/catalina.sh</exec>
      <arg>stop</arg>
    </stop>
    <pass><!-- the program is called with all args after "pass" -->
      <exec fork="false">/usr/local/jakarta-tomcat4.1/bin/catalina.sh</exec>
      <args />
    </pass>
    <force-stop /><!-- kills by pid -->
    <restart /><!-- stop; start -->
  </actions>

</daemon>

The bits mentioned above are not complete, but I've been using a
(much more simplistic) version for a couple of weeks.  If this
approach is sane, I'll try and finish this up over the weekend.
Right now the program is using libxml2, but I'd like to implement
it on top of expat, since that is already required for any of
the java progs.

  b

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing."  -- Duane Allman


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Doug Pola » Fri, 21 Mar 2003 13:27:34



> | Perhaps a knoweldgeable and kind soul can enlighten us why jdk1.3.1
> | is the only jdk for use in jboss3 and tomcat41.

> I have a patch to the daemonctl.c source that causes it to use
> JAVA_HOME, but this approach is not ideal, as there are other
> difficulties aside from which java binary to use.

> I'm taking over the jboss3 port (provided I find time to wrap
> up the loose ends), and I've been thinking that a better solution
> would be to have the daemonctl.c program call an appropriate
> shell script instead of calling the java binary directly -- the
> daemonctl.c program exists solely as a setuid/setgid wrapper
> to startup the service in question.

> I have begun to implement a daemonctl.c that uses a( set of xml)
> config file(s) to control its actions.

> sh$ ls -al /usr/local/bin/tomcat41ctl
> lrwxr-xr-x   1 root  wheel        5 May 12  2002 tomcat41ctl -> jxdaemonctl
> sh$ ls -1 /usr/local/etc/daemonctl.d/
> tomcat41ctl.xml
> jboss3ctl.xml
> jboss-tomcat.xml

> when called thru the tomcat41ctl symlink, the program will find the
> tomcat41ctl.xml config file which looks like this.

> <daemon>
>   <user>www</user>
>   <group>www</group>

>   <setenv>
>     <name>JAVA_HOME</name>
>     <value>/usr/local/jdk1.4.1</value>
>   </setenv>
>   <setenv>
>     <name>CATALINA_TMPDIR</name>
>     <value>/var/tmp/tomcat41</value>
>   </setenv>

>   <chdir>/</chdir>

>   <logs>
>    <stdout>/usr/local/jakarta-tomcat4.1/logs/stdout.log</stdout>
>    <stderr>/usr/local/jakarta-tomcat4.1/logs/stderr.log</stderr>
>   </logs>

>   <actions>
>     <start>
>       <exec>/usr/local/jakarta-tomcat4.1/bin/catalina.sh</exec>
>       <arg>run</arg>
>       <arg>-security</arg>
>     </start>
>     <stop>
>       <exec fork="false">/usr/local/jakarta-tomcat4.1/bin/catalina.sh</exec>
>       <arg>stop</arg>
>     </stop>
>     <pass><!-- the program is called with all args after "pass" -->
>       <exec fork="false">/usr/local/jakarta-tomcat4.1/bin/catalina.sh</exec>
>       <args />
>     </pass>
>     <force-stop /><!-- kills by pid -->
>     <restart /><!-- stop; start -->
>   </actions>

> </daemon>

> The bits mentioned above are not complete, but I've been using a
> (much more simplistic) version for a couple of weeks.  If this
> approach is sane, I'll try and finish this up over the weekend.
> Right now the program is using libxml2, but I'd like to implement
> it on top of expat, since that is already required for any of
> the java progs.

Sound like you have a thorough grasp of the situation.  I'll be
willing to help test your stuff if you decide to go ahead with the
ports.  Thanks for the info.

--
Regards,
Doug


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Ari Suuta » Fri, 21 Mar 2003 18:12:31


--Boundary-00=_dXYe+h5We6YEeP6
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

On Thursday 20 March 2003 06:12, Brent Verner wrote:

> I have a patch to the daemonctl.c source that causes it to use
> JAVA_HOME, but this approach is not ideal, as there are other
> difficulties aside from which java binary to use.

I have also a patched version of daemonctl.c, which
uses a configuration file in /usr/local/etc, like this:
(I'll attach the source to this mail, maybe it is useful
to others also)

tomcat4ctl.conf:

APP_HOME=/usr/local/jakarta-tomcat4.0.5
JAVA_HOME=/usr/local/linux-sun-jdk1.3.1
STDOUT_LOG=/usr/local/jakarta-tomcat4.0.5/logs/stdout.log
STDERR_LOG=/usr/local/jakarta-tomcat4.0.5/logs/stderr.log
STOP_TIMEOUT=5
PID_FILE=/var/run/tomcat4.pid
PORTVERSION=4.0.5
APP_TITLE=Jakarta Tomcat
JAVA_CMD=bin/java
JAR_FILE=bin/bootstrap.jar
JAVA_ARGS=-Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol
-Dc
atalina.home=/usr/local/jakarta-tomcat4.0.5
JAR_ARGS=start

        Ari S.

--Boundary-00=_dXYe+h5We6YEeP6
Content-Type: text/x-csrc;
  charset="iso-8859-1";
  name="daemonctl.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="daemonctl.c"

/*
 * -*- mode: Fundamental; tab-width: 4; -*-
 * ex:ts=4
 *
 * Daemon control program.
 *
 * $FreeBSD: ports/www/jakarta-tomcat4/files/daemonctl.c,v 1.6 2002/05/08 22:00:04 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/stat.h>
#include <sys/types.h>
#include <sys/uio.h>

/* The maximum size of the PID file, in bytes */
#define MAX_FILE_SIZE                   32
#define MAX_ARGS                                50

/* The interval in seconds between the checks to make sure the process
   died after a kill */
#define STOP_TIME_INTERVAL              1

#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_ACCESS_JAR_FILE                                     17
#define ERR_STDOUT_LOGFILE_OPEN                         9
#define ERR_STDERR_LOGFILE_OPEN                         10
#define ERR_FORK_FAILED                                         11
#define ERR_STAT_JAVA_HOME                                      12
#define ERR_JAVA_HOME_NOT_DIR                           13
#define ERR_STAT_JAVA_CMD                                       14
#define ERR_JAVA_CMD_NOT_FILE                           15
#define ERR_JAVA_CMD_NOT_EXECUTABLE                     16
#define ERR_CONF_FILE_OPEN                                      17
#define ERR_CONF_FILE_ERROR                                     18
#define ERR_MALLOC                                                      19
#define ERR_TOO_MANY_ARGS                                       20
#define ERR_CONFIG_MISSING                                      21

#define private static

typedef struct _confNode {

        char*                           name;
        char*                           value;
        struct _confNode*       next;

} ConfNode;

private ConfNode*       confList = NULL;
private char*           myName = "daemonctl";

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);
private void readConf(char*);
private char* getConfStr(char*);
private int   getConfInt(char*);

/**
 * 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;

    readConf(argv[0]);

        /* Parse the arguments */
        if (argc < 2) {
                printUsage();
                return 0;
        }

        setuid(geteuid());
        setgid(getegid());
        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, "%s: Illegal argument \"%s\".\n", myName, argument);
                printUsage();
                exit(ERR_ILLEGAL_ARGUMENT);
        }

        return 0;

}

/**
 * Prints usage information to stdout.
 */
void printUsage(void) {
        printf("Usage: %s [ start | stop | restart ]\n", myName);

}

/**
 * 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 */
        file = open(getConfStr("PID_FILE"), O_RDWR);
        if (file < 0) {
                printf(" [ FAILED ]\n");
                fprintf(stderr, "%s: Unable to open %s for reading and writing: ", myName, getConfStr("PID_FILE"));
                perror(NULL);
                exit(ERR_PID_FILE_NOT_FOUND);
        }

        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 */
        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, "%s: The file %s contains more than %d bytes.\n", myName, getConfStr("PID_FILE"), 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, "%s: The file %s contains an illegal character (%d) at position %d.\n", myName, getConfStr("PID_FILE"), 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, (off_t) 0, SEEK_SET);
        ftruncate(file, (off_t) 0);
        nbytes = asprintf(&buffer, "%d\n", pid);
        write(file, buffer, nbytes);
        printf(" [ DONE ]\n");

}

/**
 * Checks if the specified process is running.
 *
 * @param pid
 *    the process id, greater than 0.
 *
 * @return
 *    0 if the specified process is not running, a different value otherwise.
 */
int existsProcess(int pid) {

        int result;

        /* Check preconditions */
        assert(pid > 0);

        /* See if the process exists */
        result = kill(pid, 0);

        /* If the result is 0, then the process exists */
        if (result == 0) {
                return 1;
        } else {
                return 0;
        }

}

/**
 * Kills the process identified by the specified ID.
 *
 * @param pid
 *    the process id, greater than 0.
 */
void killProcess(int pid) {

        int result;
        unsigned int waited;
        unsigned int forced;
        unsigned int interval = STOP_TIME_INTERVAL;
        unsigned int timeout  = getConfInt("STOP_TIMEOUT");

        /* Check preconditions */
        assert(pid > 0);

        printf(">> Terminating process %d...", pid);
        result = kill(pid, SIGTERM);
        if (result < 0) {
                printf(" [ FAILED ]\n");
                fprintf(stderr, "%s: Unable to kill process %d: ", myName, pid);
                perror(NULL);
                exit(ERR_KILL_FAILED);
        }

        /* Wait until the process is actually killed */
    result = existsProcess(pid);
        for (waited=0; result == 1 && waited < timeout; waited += interval)
        {
                printf(".");
                fflush(NULL);
                sleep(interval);
        result = existsProcess(pid);
        }

        /* If the process still exists, then have no mercy and kill it */
        forced = 0;
        if (result == 1) {

                /* Force the process to die */
                result = kill(pid, SIGKILL);
                if (result == 0) {
                        forced = 1;
                        printf(" [ DONE ]\n");
                        fprintf(stderr, "%s: Process %d did not terminate within %d sec. Killed.\n", myName, timeout, pid);
                } else if (result != ESRCH) {
                        printf(" [ FAILED ]\n");
                        fprintf(stderr, "%s: Unable to kill process %d: ", myName, pid);
                        perror(NULL);
                        exit(ERR_KILL_FAILED);
                }
        }

        if (forced == 0) {
                printf(" [ DONE ]\n");
        }

}

/**
 * Starts the daemon.
 */
void start(void) {

        int file;
        int pid;
        int result;
        int stdoutLogFile;
        int stderrLogFile;
        struct stat sb;
        char    buf[512];
        char*   token;
        char*   args[MAX_ARGS];
        int             argCount;

        /* Open and read the PID file */
        printf(">> Reading PID file (%s)...", getConfStr("PID_FILE"));
        file = openPIDFile();
        pid = readPID(file);

        printf(">> Starting %s %s...", getConfStr("APP_TITLE"), getConfStr("PORTVERSION"));
        if (pid != -1) {

                /* Check if the process actually exists */
                result = existsProcess(pid);
                if (result == 1) {
                        printf(" [ FAILED ]\n");
                        fprintf(stderr, "%s: %s %s is already running, PID is %d.\n", myName, getConfStr("APP_TITLE"), getConfStr("PORTVERSION"), pid);
                        exit(ERR_ALREADY_RUNNING);
                }
        }

        /* Check if the JDK home directory is actually a directory */
        result = stat(getConfStr("JAVA_HOME"), &sb);
        if (result != 0) {
                printf(" [ FAILED ]\n");
                fprintf(stderr, "%s: Unable to stat %s: ", myName, getConfStr("JAVA_HOME"));
                perror(NULL);
                exit(ERR_STAT_JAVA_HOME);
        }
        if (!S_ISDIR(sb.st_mode)) {
                printf(" [ FAILED ]\n");
                fprintf(stderr, "%s: Java home directory %s is not a directory.\n", myName, getConfStr("JAVA_HOME"));
                exit(ERR_JAVA_HOME_NOT_DIR);
        }

        /* Check if the Java command is actually an executable regular file */
    sprintf (buf, "%s/%s", getConfStr("JAVA_HOME"), getConfStr("JAVA_CMD"));
        result = stat(buf, &sb);
        if (result != 0) {
                printf(" [ FAILED ]\n");
                fprintf(stderr, "%s: Unable to stat %s: ", myName, buf);
                perror(NULL);
...

read more »

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Sheldon Hea » Fri, 21 Mar 2003 21:37:17



Quote:> I have begun to implement a daemonctl.c that uses a( set of xml)
> config file(s) to control its actions.

Why not simply modify the ctlers to honour the JAVA_HOME envar when
present, otherwise behave the same as on other platforms?

That way, you introduce a superset of the behaviour found on other
platforms that is orthogonal with both the traditional Unix environment
paradigm (envars override defaults) and also with the Java paradigm
(JAVA_HOME means something special).

Ciao,
Sheldon.


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Milo Hys » Sat, 22 Mar 2003 01:24:18


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>


  </pre>
  <blockquote type="cite">
    <pre wrap="">I have begun to implement a daemonctl.c that uses a( set of xml)
config file(s) to control its actions.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Why not simply modify the ctlers to honour the JAVA_HOME envar when
present, otherwise behave the same as on other platforms?

That way, you introduce a superset of the behaviour found on other
platforms that is orthogonal with both the traditional Unix environment
paradigm (envars override defaults) and also with the Java paradigm
(JAVA_HOME means something special).

  </pre>
</blockquote>
I agree. At the very least, I would expect a FreeBSD port to provide
the option to behave like the official stock release.<br>
<pre class="moz-signature" cols="72">--
Milo Hyson
*Life Labs
</pre>
</body>
</html>


with "unsubscribe freebsd-java" in the body of the message

 
 
 

Specifying jdk for tomcat 4.1.18

Post by Brent Vern » Sat, 22 Mar 2003 01:32:18


[2003-03-20 08:13] Milo Hyson said:
|

|    
|         I have begun to implement a daemonctl.c that uses a( set of xml)
|         config file(s) to control its actions.
|            
|     Why not simply modify the ctlers to honour the JAVA_HOME envar when
|     present, otherwise behave the same as on other platforms?
|
|     That way, you introduce a superset of the behaviour found on other
|     platforms that is orthogonal with both the traditional Unix environment
|     paradigm (envars override defaults) and also with the Java paradigm
|     (JAVA_HOME means something special).
|    
| I agree. At the very least, I would expect a FreeBSD port to provide the option
| to behave like the official stock release.

  I agree wholly with (both of) you on this issue, which is why
I've tried to implement a flexible setuid/setgid wrapper around
the scripts used by the official releases.  I only chose to use
xml because I didn't want to write YACFP (yet another config file
parser).  The calling environment is passed to the script, so the
setuid wrapper _could_ be as simple as calling thru to the
/usr/local/jakarta-tomcat4.1/bin/catalina.sh script.

  b

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing."  -- Duane Allman


with "unsubscribe freebsd-java" in the body of the message

 
 
 

1. Specifying jdk for tomcat 4.1.18


You're entitled to disagree, but at least take the time to read the
entire post to which you respond when you do so.  You went on to argue
against a point I didn't make. :-)

The proposition I put forward would result in the software working very
much like the standard distribution, while the additional functionality
that several people have requested was made available in a traditional
and familiar fashion.

Ciao,
Sheldon.


with "unsubscribe freebsd-java" in the body of the message

2. ipfilters, NAT and MAC address problem

3. Jakarta-Tomcat 4.1.18 + FreeBSD + linux-sun-jdk14 won't start ...

4. Resizeing ext2 partition

5. mod_jk for tomcat 4.1.18 and Aix5.1

6. nvidia kernel module under 2.4.0-test11

7. jakarta-tomcat 4.1.18 and freebsd 5.0 problems

8. bnc

9. [Fwd: Re: Tomcat 4.1.18, Apache 1.3.27 and jk?]

10. Tomcat 4.1.18, Apache 1.3.27 and jk?

11. X11 , AIX 4.3.3.0 , JAVA JDK 1.3.1 , TOMCAT 4.1.18 AND DYNAMIC JPEG

12. FreeBSD 4.6, JDK 1.4.0, Blackdown JDK 1.3.1, running Tomcat 4.0.

13. Update tomcat port to jdk 1.3.1