diff options
author | Herve Quiroz <hq@FreeBSD.org> | 2005-02-24 22:50:29 +0000 |
---|---|---|
committer | Herve Quiroz <hq@FreeBSD.org> | 2005-02-24 22:50:29 +0000 |
commit | d0164eff5a728dd97f4b437cca3d37ab55062259 (patch) | |
tree | e1ceb5c264c1295bbcaf6d7c9e2d02814ac30181 /www/resin3/files | |
parent | c8ee1425883336bb2ede48897308ca5cdaa5ddd3 (diff) | |
download | ports-d0164eff5a728dd97f4b437cca3d37ab55062259.tar.gz ports-d0164eff5a728dd97f4b437cca3d37ab55062259.zip |
- Update to 3.0.11 [1]
- Replace perl wrapper with a new python control script and an RCng startup
script [1]
- Update to bsd.java.mk 2.0
- Add $FreeBSD$ tags
- Tweak pkg-descr to calm portlint
- Use provided ${FMT} macro
PR: 77989 [1]
Submitted by: maintainer [1]
Notes
Notes:
svn path=/head/; revision=129705
Diffstat (limited to 'www/resin3/files')
-rw-r--r-- | www/resin3/files/install.sh | 6 | ||||
-rw-r--r-- | www/resin3/files/patch-apache1-Makefile.in | 2 | ||||
-rw-r--r-- | www/resin3/files/patch-apache2-Makefile.in | 2 | ||||
-rw-r--r-- | www/resin3/files/patch-configure | 2 | ||||
-rw-r--r-- | www/resin3/files/patch-resin.conf | 2 | ||||
-rw-r--r-- | www/resin3/files/patch-wrapper | 8 | ||||
-rw-r--r-- | www/resin3/files/pkg-message.in | 14 | ||||
-rw-r--r-- | www/resin3/files/resin.sh.in | 73 | ||||
-rw-r--r-- | www/resin3/files/resinctl | 190 |
9 files changed, 237 insertions, 62 deletions
diff --git a/www/resin3/files/install.sh b/www/resin3/files/install.sh index 6043a27c40ac..8a628185e34a 100644 --- a/www/resin3/files/install.sh +++ b/www/resin3/files/install.sh @@ -1,4 +1,6 @@ #! /bin/sh +# +# $FreeBSD$ set -e @@ -33,7 +35,7 @@ install %%WRKDIR%%/resin.sh.in %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh chmod 755 %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh echo Installed %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh -install %%WRKSRC%%/bin/wrapper.pl %%PREFIX%%/sbin/%%APP_NAME%%ctl +install %%WRKDIR%%/resinctl %%PREFIX%%/sbin/%%APP_NAME%%ctl echo Installed %%PREFIX%%/sbin/%%APP_NAME%%ctl test -d %%APP_HOME%% || mkdir %%APP_HOME%% @@ -50,4 +52,4 @@ list() ( cd %%WRKSRC%% && find %%COPYDIRS%% -type d -empty -delete ) echo Installing in %%APP_HOME%% -list | xargs tar -C %%WRKSRC%% -cf- | tar -C %%APP_HOME%% -xpf- +list | ( cd %%WRKSRC%% && cpio -pdm -L -R $RUNASUSER:$GROUP %%APP_HOME%% ) diff --git a/www/resin3/files/patch-apache1-Makefile.in b/www/resin3/files/patch-apache1-Makefile.in index d227228139de..ad61eca13003 100644 --- a/www/resin3/files/patch-apache1-Makefile.in +++ b/www/resin3/files/patch-apache1-Makefile.in @@ -1,3 +1,5 @@ +$FreeBSD$ + --- src/c/apache1/Makefile.in.orig Mon Oct 11 11:34:53 2004 +++ src/c/apache1/Makefile.in Mon Oct 11 12:44:59 2004 @@ -38,8 +38,7 @@ diff --git a/www/resin3/files/patch-apache2-Makefile.in b/www/resin3/files/patch-apache2-Makefile.in index d7d041eb7213..5f8eade528a7 100644 --- a/www/resin3/files/patch-apache2-Makefile.in +++ b/www/resin3/files/patch-apache2-Makefile.in @@ -1,3 +1,5 @@ +$FreeBSD$ + --- src/c/apache2/Makefile.in.orig Mon Oct 11 11:34:53 2004 +++ src/c/apache2/Makefile.in Mon Oct 11 12:44:59 2004 @@ -38,8 +38,7 @@ diff --git a/www/resin3/files/patch-configure b/www/resin3/files/patch-configure index 503fd1585c3e..67ad30e33399 100644 --- a/www/resin3/files/patch-configure +++ b/www/resin3/files/patch-configure @@ -1,3 +1,5 @@ +$FreeBSD$ + --- configure.orig Tue Oct 12 18:34:32 2004 +++ configure Tue Oct 12 18:34:48 2004 @@ -8487,20 +8487,6 @@ diff --git a/www/resin3/files/patch-resin.conf b/www/resin3/files/patch-resin.conf index 4ad27e4a95ca..dcc5cf7a3a65 100644 --- a/www/resin3/files/patch-resin.conf +++ b/www/resin3/files/patch-resin.conf @@ -1,3 +1,5 @@ +$FreeBSD$ + --- conf/resin.conf.orig Tue Jun 15 10:50:09 2004 +++ conf/resin.conf Tue Jun 15 10:50:47 2004 @@ -158,7 +158,7 @@ diff --git a/www/resin3/files/patch-wrapper b/www/resin3/files/patch-wrapper deleted file mode 100644 index 7d3f9aadfb18..000000000000 --- a/www/resin3/files/patch-wrapper +++ /dev/null @@ -1,8 +0,0 @@ ---- bin/wrapper.pl.in.orig Sat Oct 4 09:45:23 2003 -+++ bin/wrapper.pl.in Sat Oct 4 09:45:43 2003 -@@ -1,4 +1,4 @@ --#! @PERL@ -+#! %%PERL%% - # - # Copyright(c) 1998-2002 Caucho Technology - # diff --git a/www/resin3/files/pkg-message.in b/www/resin3/files/pkg-message.in index e4d9e708a1ef..ce12375aa0b6 100644 --- a/www/resin3/files/pkg-message.in +++ b/www/resin3/files/pkg-message.in @@ -1,8 +1,14 @@ Resin is now installed in %%APP_HOME%% -You may want to start it using the -startup script installed as %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh and then point -your web browser to the default home page at http://localhost:%%PORT%%/ to read -the documentation and test the samples. +You may want to activate it in /etc/rc.conf: + +%%APP_NAME%%_enable="YES" + +Then start it: + +env - %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh start + +And point your web browser to the default home page at +http://localhost:%%PORT%%/ to read the documentation and test the samples. Resin configuration is located at %%PREFIX%%/etc/%%APP_NAME%%/resin.xml diff --git a/www/resin3/files/resin.sh.in b/www/resin3/files/resin.sh.in index d2c7816829f2..a60b51bbcf68 100644 --- a/www/resin3/files/resin.sh.in +++ b/www/resin3/files/resin.sh.in @@ -1,54 +1,31 @@ #!/bin/sh # -# Resin startup script. +# $FreeBSD$ # -# Borrowed from jakarta-tomcat41 + +# PROVIDE: %%APP_NAME%% + # -# $FreeBSD$ +# Add the following line to /etc/rc.conf to enable %%APP_NAME%%: +# +# %%APP_NAME%%_enable="YES" # -# Determine PREFIX -if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/${0##*/}\$"); then - echo "$0: Cannot determine the PREFIX" >&2 - exit 1 -fi - -# Set some variables -MYSELF=`basename $0` -ARGS="-conf $PREFIX/etc/%%APP_NAME%%/resin.xml \ --chdir \ --name %%APP_NAME%% \ --class com.caucho.server.resin.Resin \ --pid %%PID_FILE%%" -PATH=/usr/sbin:/usr/bin:/bin - -unset CLASSPATH -export JAVA_HOME=%%JAVA_HOME%% -export RESIN_HOME=$PREFIX/%%APP_NAME%% - -set -e - -case "$1" in - start) - echo -n ' ' - truncate -s 0 %%PID_FILE%% - chown %%RUNASUSER%%:%%GROUP%% %%PID_FILE%% - chmod 600 %%PID_FILE%% - su -f -m %%RUNASUSER%% -c "exec $PREFIX/sbin/%%APP_NAME%%ctl $ARGS start" \ - >/dev/null && echo -n '%%APP_NAME%%' - ;; - - stop) - echo -n ' ' - chown %%RUNASUSER%%:%%GROUP%% %%PID_FILE%% - chmod 600 %%PID_FILE%% - su -f -m %%RUNASUSER%% -c "exec $PREFIX/sbin/%%APP_NAME%%ctl $ARGS stop" \ - >/dev/null 2>&1 ; echo -n '%%APP_NAME%%' - ;; - *) - echo "" - echo "Usage: ${MYSELF} { start | stop }" - echo "" - exit 64 - ;; -esac +. /etc/rc.subr + +name=%%APP_NAME%% +rcvar=`set_rcvar` + +command=%%PREFIX%%/sbin/%%APP_NAME%%ctl +command_args="$1" +pidfile=%%PID_FILE%% +procname=%%JAVA%% + +# set defaults + +%%APP_NAME%%_enable=${%%APP_NAME%%_enable:-"NO"} +%%APP_NAME%%_user=${%%APP_NAME%%_user:-"www"} +%%APP_NAME%%_group=${%%APP_NAME%%_group:-"www"} + +load_rc_config ${name} +run_rc_command "$1" diff --git a/www/resin3/files/resinctl b/www/resin3/files/resinctl new file mode 100644 index 000000000000..764032cc9e93 --- /dev/null +++ b/www/resin3/files/resinctl @@ -0,0 +1,190 @@ +#! %%PYTHON_CMD%% + +################################################################################ +# Author: Jean-Baptiste Quenot <jb.quenot@caraldi.com> +# Purpose: Manage resin pid file and log files +# Date Created: 2005-01-21 15:43:19 +# Revision: $FreeBSD$ +################################################################################ +# Copyright (c) 2004, Jean-Baptiste Quenot <jb.quenot@caraldi.com> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * The name of the contributors may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +################################################################################ +# +# Files handled by this script (pid file, log files) must reside in a writable +# directory, ie the directory must be owned by the user running the program. + +import sys, os, signal, time, stat, re + +def classpath(): + classpath = [] + resin_libdir = APP_HOME + "/lib" + java_libdir = os.environ['JAVA_HOME'] + "/lib" + for libdir in [resin_libdir, java_libdir]: + for file in os.listdir(libdir): + if re.search("\.jar$", file): + classpath.append(libdir + "/" + file) + return ':'.join(classpath) + +# -socketwait 12345 +# -stdout $APP_HOME/log/stdout.log +# -stderr $APP_HOME/log/stderr.log + +def readProcessId(): + f = open(PID_FILE, 'r') + pid = int(f.readline()) + f.close() + return pid + +def isProgramRunning(pid): + # Send a dummy signal to the process. If it died, an exception is + # thrown + try: + os.kill(pid, signal.SIGCONT) + return 1 + except OSError: + return 0 + +def usage(): + print >> sys.stderr, "Usage: %s {start|stop|restart}" % sys.argv[0] + +def start(): + cwd = os.getcwd() + if os.path.exists(PID_FILE): + # Read the process id + pid = readProcessId() + + if isProgramRunning(pid): + print >> sys.stderr, '%s already started' % APP_NAME + sys.exit(3) + + if not(os.path.exists(COMMAND)): + print >> sys.stderr, '%s cannot be found' % COMMAND + sys.exit(3) + + # Append program output to a log file + l = open(LOG_FILE, 'a') + orig_stderr = os.dup(sys.stderr.fileno()) + os.dup2(l.fileno(), sys.stdout.fileno()) + os.dup2(l.fileno(), sys.stderr.fileno()) + + finfo = os.stat(COMMAND)[stat.ST_MODE] + executable = stat.S_IMODE(finfo) & 0111 + if not(executable): + sys.stderr = os.fdopen(orig_stderr, 'w') + print >> sys.stderr, 'Cannot run %s, execute bit is missing' % COMMAND + sys.exit(5) + + if APP_HOME: + # Change current directory to APP_HOME + os.chdir(APP_HOME) + + # Start program in the background + pid = os.spawnv(os.P_NOWAIT, COMMAND, ARGS) + + # Wait a little + time.sleep(.4) + (unused_pid, status) = os.waitpid(pid, os.WNOHANG) + + # Check program exit status, if available + if unused_pid != 0 and os.WIFEXITED(status): + sys.stderr = os.fdopen(orig_stderr, 'w') + print >> sys.stderr, 'Could not start %s. Check %s for errors.' % (APP_NAME, LOG_FILE) + sys.exit(2) + + # It's alive, so write down the process id + os.chdir(cwd) + f = open(PID_FILE, 'w') + print >> f, pid + f.close() + +def warnNotRunning(): + if sys.argv[1] == "stop": + print >> sys.stderr, '%s is not running' % APP_NAME + else: + print >> sys.stderr, 'Warning: %s was not running' % APP_NAME + +def cleanup(): + os.unlink(PID_FILE) + +def stop(): + if os.path.exists(PID_FILE): + # Read the process id + pid = readProcessId() + else: + warnNotRunning() + return + + if not(isProgramRunning(pid)): + warnNotRunning() + cleanup() + return + + # Terminate program + os.kill(pid, signal.SIGTERM) + + while isProgramRunning(pid): + time.sleep(.1) + + cleanup() + +if __name__ == '__main__': + LOG_FILE = "%%LOG_FILE%%" + APP_NAME = "%%APP_NAME%%" + APP_HOME = "%%APP_HOME%%" + CONTROL_PROGRAM = "%%APP_NAME%%ctl" + PID_FILE = "%%PID_FILE%%" + COMMAND = "%%JAVA%%" + ARGS = [COMMAND] + + if os.environ.has_key('JAVA_OPTS'): + ARGS += os.environ['JAVA_OPTS'].split(" ") + + ARGS += [ + "-Dresin.home=%%APP_HOME%%", + "-Djava.util.logging.manager=com.caucho.log.LogManagerImpl", + "com.caucho.server.resin.Resin", + "-conf", "%%PREFIX%%/etc/%%APP_NAME%%/resin.xml" + ] + + os.environ['JAVA_HOME'] = "%%JAVA_HOME%%" + os.environ['CLASSPATH'] = classpath() + + if len(sys.argv) != 2: + usage() + sys.exit(1) + + if sys.argv[1] == "start": + start() + + elif sys.argv[1] == "stop": + stop() + + elif sys.argv[1] == "restart": + stop() + start() + + else: + usage() + sys.exit(1) |