View | Details | Raw Unified | Return to bug 77988
Collapse All | Expand All

(-)./Makefile (-72 / +71 lines)
Lines 2-60 Link Here
2
# Whom:                                Jean-Baptiste Quenot <jb.quenot@caraldi.com>
2
# Whom:                                Jean-Baptiste Quenot <jb.quenot@caraldi.com>
3
# Date Created:                        2002-07-15 15:00:43
3
# Date Created:                        2002-07-15 15:00:43
4
#
4
#
5
# ex:ts=20:sw=20
6
#
7
# $FreeBSD: ports/www/resin2/Makefile,v 1.4 2004/07/02 22:10:15 glewis Exp $
5
# $FreeBSD: ports/www/resin2/Makefile,v 1.4 2004/07/02 22:10:15 glewis Exp $
8
#
6
#
9
7
10
PORTNAME=	resin
8
PORTNAME=		resin
11
PORTVERSION=	2.1.14
9
PORTVERSION=		2.1.16
12
CATEGORIES=	www java
10
CATEGORIES=		www java
13
MASTER_SITES=	http://www.caucho.com/download/
11
MASTER_SITES=		http://www.caucho.com/download/
14
12
15
MAINTAINER=	jb.quenot@caraldi.com
13
MAINTAINER=		jb.quenot@caraldi.com
16
COMMENT=	Resin, a Java-based Application Server, 2.x branch
14
COMMENT=		Resin, a Java-based Application Server, 2.x branch
17
15
18
USE_JAVA=	1.2+
16
USE_JAVA=		1.2+
19
HAS_CONFIGURE=	yes
17
HAS_CONFIGURE=		yes
20
USE_PERL5=	yes
18
USE_PYTHON=		yes
21
USE_REINPLACE=	yes
19
USE_REINPLACE=		yes
22
20
23
# Customizable settings
21
# Customizable settings
24
RUNASUSER?=	www
22
RUNASUSER?=		www
25
RUNASUID?=	80
23
RUNASUID?=		80
26
GROUP?=	${RUNASUSER}
24
GROUP?=			${RUNASUSER}
27
GID?=	${RUNASUID}
25
GID?=			${RUNASUID}
28
PORT?=	8080
26
PORT?=			8080
29
# Do not use PKGNAMESUFFIX here because version info is already in PORTVERSION
27
# Do not use PKGNAMESUFFIX here because version info is already in PORTVERSION
30
# If we used PKGNAMESUFFIX, the package name would be resin2-2.1.11
28
# If we used PKGNAMESUFFIX, the package name would be resin2-2.1.11
31
APP_NAME_SUFFIX=	${PORTVERSION:C/\..*$//}
29
APP_NAME_SUFFIX=	${PORTVERSION:C/\..*$//}
32
APP_NAME?=	${PORTNAME}${APP_NAME_SUFFIX}
30
APP_NAME?=		${PORTNAME}${APP_NAME_SUFFIX}
33
LATEST_LINK=	${APP_NAME}
31
LATEST_LINK=		${APP_NAME}
34
APP_HOME?=	${PREFIX}/${APP_NAME}
32
APP_HOME?=		${PREFIX}/${APP_NAME}
35
WITH_APACHE?=	NO
33
WITH_APACHE?=		NO
36
WITH_APACHE2?=	NO
34
WITH_APACHE2?=		NO
37
PID_FILE?=	/var/run/${APP_NAME}.pid
35
PID_FILE?=		${APP_HOME}/${APP_NAME}.pid
36
LOG_FILE?=		${APP_HOME}/${APP_NAME}.log
38
37
39
# Other settings
38
# Other settings
40
APXS?=	${LOCALBASE}/sbin/apxs
39
APXS?=			${LOCALBASE}/sbin/apxs
41
MOD_DIR?=	`${APXS} -q LIBEXECDIR`
40
PKGINSTALL=		${WRKDIR}/pkg-install
42
PKGINSTALL=	${WRKDIR}/pkg-install
41
PKGDEINSTALL=		${WRKDIR}/pkg-deinstall
43
PKGDEINSTALL=	${WRKDIR}/pkg-deinstall
42
PKGMESSAGE=		${WRKDIR}/pkg-message
44
PKGMESSAGE=	${WRKDIR}/pkg-message
45
# We need WRKSRC and WRKDIR right now so define them "manually"
43
# We need WRKSRC and WRKDIR right now so define them "manually"
46
WRKSRC=	${WRKDIR}/${PORTNAME}-${PORTVERSION}
44
WRKSRC=			${WRKDIR}/${PORTNAME}-${PORTVERSION}
47
WRKDIR?=	${WRKDIRPREFIX}${.CURDIR}/work
45
WRKDIR?=		${WRKDIRPREFIX}${.CURDIR}/work
48
REINPLACE_FILES=	${WRKSRC}/src/c/plugin/apache/Makefile.in \
46
REINPLACE_FILES=	${WRKSRC}/src/c/plugin/apache/Makefile.in \
49
	${WRKSRC}/src/c/plugin/apache2/Makefile.in
47
			${WRKSRC}/src/c/plugin/apache2/Makefile.in
50
REPLACE_FILES=	${FILESDIR}/pkg-install \
48
REPLACE_FILES=		${FILESDIR}/pkg-install \
51
	${FILESDIR}/pkg-deinstall \
49
			${FILESDIR}/pkg-deinstall \
52
	${FILESDIR}/install.sh \
50
			${FILESDIR}/install.sh \
53
	${FILESDIR}/pkg-message.in \
51
			${FILESDIR}/pkg-message.in \
54
	${WRKSRC}/conf/resin.conf \
52
			${WRKSRC}/conf/resin.conf \
55
	${WRKSRC}/bin/wrapper.pl.in \
53
			${FILESDIR}/resinctl \
56
	${FILESDIR}/resin.sh.in
54
			${FILESDIR}/resin.sh.in
57
COPYDIRS=	doc lib libexec xsl
55
COPYDIRS=		doc lib libexec xsl
56
57
.include <bsd.port.pre.mk>
58
58
59
# Pass JAVA_HOME as determined by bsd.java.mk
59
# Pass JAVA_HOME as determined by bsd.java.mk
60
CONFIGURE_ARGS+=	--with-java-home=${JAVA_HOME}
60
CONFIGURE_ARGS+=	--with-java-home=${JAVA_HOME}
Lines 64-111 Link Here
64
#
64
#
65
# Apache 1.3
65
# Apache 1.3
66
#
66
#
67
BUILD_DEPENDS+=	${APXS}:${PORTSDIR}/www/apache13
67
BUILD_DEPENDS+=		${APXS}:${PORTSDIR}/www/apache13
68
CONFIGURE_ARGS+=	--with-apxs=${APXS}
68
CONFIGURE_ARGS+=	--with-apxs=${APXS}
69
PLIST_SUB+=	MOD_DIR=libexec/apache
69
PLIST_SUB+=		MOD_DIR=libexec/apache
70
# Allow apxs invocations
70
# Allow apxs invocations
71
PLIST_SUB+=	APACHE=""
71
PLIST_SUB+=		APACHE=""
72
.elif defined(WITH_APACHE2) && (${WITH_APACHE2} == yes || ${WITH_APACHE2} == YES)
72
.elif defined(WITH_APACHE2) && (${WITH_APACHE2} == yes || ${WITH_APACHE2} == YES)
73
#
73
#
74
# Apache 2
74
# Apache 2
75
#
75
#
76
BUILD_DEPENDS+=	${APXS}:${PORTSDIR}/www/apache2
76
BUILD_DEPENDS+=		${APXS}:${PORTSDIR}/www/apache2
77
CONFIGURE_ARGS+=	--with-apxs=${APXS}
77
CONFIGURE_ARGS+=	--with-apxs=${APXS}
78
PLIST_SUB+=	MOD_DIR=libexec/apache2
78
PLIST_SUB+=		MOD_DIR=libexec/apache2
79
# Allow apxs invocations
79
# Allow apxs invocations
80
PLIST_SUB+=	APACHE=""
80
PLIST_SUB+=		APACHE=""
81
.else
81
.else
82
PLIST_SUB+=	MOD_DIR="@comment "
82
PLIST_SUB+=		MOD_DIR="@comment "
83
# Prevent apxs invocations
83
# Prevent apxs invocations
84
PLIST_SUB+=	APACHE="@comment "
84
PLIST_SUB+=		APACHE="@comment "
85
.endif
85
.endif
86
86
87
PLIST_SUB+=	APP_NAME=${APP_NAME}
87
PLIST_SUB+=		APP_NAME=${APP_NAME}
88
PLIST_SUB+=	APXS=${APXS}
88
PLIST_SUB+=		APXS=${APXS}
89
89
90
SUBSTITUTIONS=	-e "s|%%APP_HOME%%|${APP_HOME}|g" \
90
SUBSTITUTIONS=		-e "s|%%APP_HOME%%|${APP_HOME}|g" \
91
	-e "s|%%APP_NAME%%|${APP_NAME}|g" \
91
			-e "s|%%APP_NAME%%|${APP_NAME}|g" \
92
	-e "s|%%APXS%%|${APXS}|g" \
92
			-e "s|%%APXS%%|${APXS}|g" \
93
	-e "s|%%COPYDIRS%%|${COPYDIRS}|g" \
93
			-e "s|%%COPYDIRS%%|${COPYDIRS}|g" \
94
	-e "s|%%FILESDIR%%|${FILESDIR}|g" \
94
			-e "s|%%FILESDIR%%|${FILESDIR}|g" \
95
	-e "s|%%GROUP%%|${GROUP}|g" \
95
			-e "s|%%GROUP%%|${GROUP}|g" \
96
	-e "s|%%GID%%|${GID}|g" \
96
			-e "s|%%GID%%|${GID}|g" \
97
	-e "s|%%JAVA_HOME%%|${JAVA_HOME}|g" \
97
			-e "s|%%JAVA_HOME%%|${JAVA_HOME}|g" \
98
	-e "s|%%PERL%%|${PERL}|g" \
98
			-e "s|%%JAVA%%|${JAVA}|g" \
99
	-e "s|%%PID_FILE%%|${PID_FILE}|g" \
99
			-e "s|%%LOG_FILE%%|${LOG_FILE}|g" \
100
	-e "s|%%PORT%%|${PORT}|g" \
100
			-e "s|%%PYTHON_CMD%%|${PYTHON_CMD}|g" \
101
	-e "s|%%PORTNAME%%|${PORTNAME}|g" \
101
			-e "s|%%PID_FILE%%|${PID_FILE}|g" \
102
	-e "s|%%PREFIX%%|${PREFIX}|g" \
102
			-e "s|%%PORT%%|${PORT}|g" \
103
	-e "s|%%RUNASUID%%|${RUNASUID}|g" \
103
			-e "s|%%PORTNAME%%|${PORTNAME}|g" \
104
	-e "s|%%RUNASUSER%%|${RUNASUSER}|g" \
104
			-e "s|%%PREFIX%%|${PREFIX}|g" \
105
	-e "s|%%WRKDIR%%|${WRKDIR}|g" \
105
			-e "s|%%RUNASUID%%|${RUNASUID}|g" \
106
	-e "s|%%WRKSRC%%|${WRKSRC}|g"
106
			-e "s|%%RUNASUSER%%|${RUNASUSER}|g" \
107
107
			-e "s|%%WRKDIR%%|${WRKDIR}|g" \
108
.include <bsd.port.pre.mk>
108
			-e "s|%%WRKSRC%%|${WRKSRC}|g"
109
109
110
post-patch:
110
post-patch:
111
.for FILE in ${REINPLACE_FILES}
111
.for FILE in ${REINPLACE_FILES}
Lines 127-137 Link Here
127
	@${ECHO_CMD} "    CauchoConfigFile ${PREFIX}/etc/${APP_NAME}.xml" >> ${PKGMESSAGE}
127
	@${ECHO_CMD} "    CauchoConfigFile ${PREFIX}/etc/${APP_NAME}.xml" >> ${PKGMESSAGE}
128
	@${ECHO_CMD} "</IfModule>" >> ${PKGMESSAGE}
128
	@${ECHO_CMD} "</IfModule>" >> ${PKGMESSAGE}
129
.endif
129
.endif
130
	@${MV} ${WRKDIR}/wrapper.pl.in ${WRKSRC}/bin/wrapper.pl.in
131
130
132
# Resin does not handle installation, so proceed now
131
# Resin does not handle installation, so proceed now
133
post-install:
132
post-install:
134
	@${SH} ${WRKDIR}/install.sh
133
	@${SETENV} RUNASUSER=${RUNASUSER} GROUP=${GROUP} ${SH} ${WRKDIR}/install.sh
135
	@${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
134
	@${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
136
	@${ECHO_CMD}
135
	@${ECHO_CMD}
137
	@${ECHO_CMD} "********************************************************************************"
136
	@${ECHO_CMD} "********************************************************************************"
(-)./distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
MD5 (resin-2.1.14.tar.gz) = 03d1ce8746ba3a5082298fd617929620
1
MD5 (resin-2.1.16.tar.gz) = 0651cfa42705397be714cee27556b028
2
SIZE (resin-2.1.14.tar.gz) = 3305648
2
SIZE (resin-2.1.16.tar.gz) = 3312495
(-)./files/install.sh (-2 / +2 lines)
Lines 28-34 Link Here
28
chmod 755 %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh
28
chmod 755 %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh
29
echo Installed %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh
29
echo Installed %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh
30
30
31
install %%WRKSRC%%/bin/wrapper.pl %%PREFIX%%/sbin/%%APP_NAME%%ctl
31
install %%WRKDIR%%/resinctl %%PREFIX%%/sbin/%%APP_NAME%%ctl
32
echo Installed %%PREFIX%%/sbin/%%APP_NAME%%ctl
32
echo Installed %%PREFIX%%/sbin/%%APP_NAME%%ctl
33
33
34
test -d %%APP_HOME%% || mkdir %%APP_HOME%%
34
test -d %%APP_HOME%% || mkdir %%APP_HOME%%
Lines 45-48 Link Here
45
( cd %%WRKSRC%% && find %%COPYDIRS%% -type d -empty -delete )
45
( cd %%WRKSRC%% && find %%COPYDIRS%% -type d -empty -delete )
46
46
47
echo Installing in %%APP_HOME%%
47
echo Installing in %%APP_HOME%%
48
list | xargs tar -C %%WRKSRC%% -cf- | tar -C %%APP_HOME%% -xpf-
48
list | ( cd %%WRKSRC%% && cpio -pdm -L -R $RUNASUSER:$GROUP %%APP_HOME%% )
(-)./files/patch-wrapper (-8 lines)
Lines 1-8 Link Here
1
--- bin/wrapper.pl.in.orig	Sat Oct  4 09:45:23 2003
2
+++ bin/wrapper.pl.in	Sat Oct  4 09:45:43 2003
3
@@ -1,4 +1,4 @@
4
-#! @PERL@
5
+#! %%PERL%%
6
 #
7
 # Copyright(c) 1998-2002 Caucho Technology
8
 #
(-)./files/pkg-message.in (-4 / +14 lines)
Lines 1-4 Link Here
1
Resin is now installed in %%APP_HOME%%.  You may want to start it using the
1
Resin is now installed in %%APP_HOME%%
2
startup script installed as %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh, and then point
2
3
your web browser to the default home page at http://localhost:%%PORT%%/ to read
3
You may want to activate it in /etc/rc.conf:
4
the doc.  Resin can be configured using %%PREFIX%%/etc/%%APP_NAME%%.xml.
4
5
%%APP_NAME%%_enable="YES"
6
7
Then start it:
8
9
env - %%PREFIX%%/etc/rc.d/%%APP_NAME%%.sh start
10
11
And point your web browser to the default home page at
12
http://localhost:%%PORT%%/ to read the documentation and test the samples.
13
14
Resin configuration is located at %%PREFIX%%/etc/%%APP_NAME%%.xml
(-)./files/resin.sh.in (-48 / +25 lines)
Lines 1-54 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# Resin startup script.
3
# $FreeBSD: ports/www/resin2/files/resin.sh.in,v 1.2 2004/07/02 22:10:15 glewis Exp $
4
#
4
#
5
# Borrowed from jakarta-tomcat41
5
6
# PROVIDE: %%APP_NAME%%
7
6
#
8
#
7
# $FreeBSD: ports/www/resin2/files/resin.sh.in,v 1.2 2004/07/02 22:10:15 glewis Exp $
9
# Add the following line to /etc/rc.conf to enable %%APP_NAME%%:
10
#
11
# %%APP_NAME%%_enable="YES"
8
#
12
#
9
13
10
# Determine PREFIX
14
. /etc/rc.subr
11
if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/${0##*/}\$"); then
15
12
    echo "$0: Cannot determine the PREFIX" >&2
16
name=%%APP_NAME%%
13
    exit 1
17
rcvar=`set_rcvar`
14
fi
18
15
19
command=%%PREFIX%%/sbin/%%APP_NAME%%ctl
16
# Set some variables
20
command_args="$1"
17
MYSELF=`basename $0`
21
pidfile=%%PID_FILE%%
18
ARGS="-conf $PREFIX/etc/%%APP_NAME%%.xml \
22
procname=%%JAVA%%
19
-chdir \
23
20
-name %%APP_NAME%% \
24
# set defaults
21
-class com.caucho.server.http.HttpServer \
25
22
-pid %%PID_FILE%%"
26
%%APP_NAME%%_enable=${%%APP_NAME%%_enable:-"NO"}
23
PATH=/usr/sbin:/usr/bin:/bin
27
%%APP_NAME%%_user=${%%APP_NAME%%_user:-"www"}
24
28
%%APP_NAME%%_group=${%%APP_NAME%%_group:-"www"}
25
unset CLASSPATH
29
26
export JAVA_HOME=%%JAVA_HOME%%
30
load_rc_config ${name}
27
export RESIN_HOME=$PREFIX/%%APP_NAME%%
31
run_rc_command "$1"
28
29
set -e
30
31
case "$1" in
32
    start)
33
        echo -n ' '
34
        truncate -s 0 %%PID_FILE%%
35
        chown %%RUNASUSER%%:%%GROUP%% %%PID_FILE%%
36
        chmod 600 %%PID_FILE%%
37
        su -f -m %%RUNASUSER%% -c "exec $PREFIX/sbin/%%APP_NAME%%ctl $ARGS start" \
38
            >/dev/null && echo -n '%%APP_NAME%%'
39
        ;;
40
41
    stop)
42
        echo -n ' '
43
        chown %%RUNASUSER%%:%%GROUP%% %%PID_FILE%%
44
        chmod 600 %%PID_FILE%%
45
        su -f -m %%RUNASUSER%% -c "exec $PREFIX/sbin/%%APP_NAME%%ctl $ARGS stop" \
46
            >/dev/null 2>&1 ; echo -n '%%APP_NAME%%'
47
        ;;
48
    *)
49
        echo ""
50
        echo "Usage: ${MYSELF} { start | stop }"
51
        echo ""
52
        exit 64
53
        ;;
54
esac
(-)./files/resinctl (+189 lines)
Line 0 Link Here
1
#! %%PYTHON_CMD%%
2
3
################################################################################
4
# Author:        Jean-Baptiste Quenot <jb.quenot@caraldi.com>
5
# Purpose:       Manage resin pid file and log files
6
# Date Created:  2005-01-21 15:43:19
7
# Revision:      $FreeBSD: ports/www/cocoon/files/cocoonctl,v 1.1 2004/07/01 22:30:19 glewis Exp $
8
################################################################################
9
# Copyright (c) 2004, Jean-Baptiste Quenot <jb.quenot@caraldi.com>
10
# All rights reserved.
11
#
12
# Redistribution and use in source and binary forms, with or without
13
# modification, are permitted provided that the following conditions are met:
14
#
15
# * Redistributions of source code must retain the above copyright notice, this
16
#   list of conditions and the following disclaimer.
17
# * Redistributions in binary form must reproduce the above copyright notice,
18
#   this list of conditions and the following disclaimer in the documentation
19
#   and/or other materials provided with the distribution.
20
# * The name of the contributors may not be used to endorse or promote products
21
#   derived from this software without specific prior written permission.
22
#
23
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
27
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
################################################################################
34
#
35
# Files handled by this script (pid file, log files) must reside in a writable
36
# directory, ie the directory must be owned by the user running the program.
37
38
import sys, os, signal, time, stat, re
39
40
def classpath():
41
    classpath = []
42
    resin_libdir = APP_HOME + "/lib"
43
    java_libdir = os.environ['JAVA_HOME'] + "/lib"
44
    for libdir in [resin_libdir, java_libdir]:
45
        for file in os.listdir(libdir):
46
            if re.search("\.jar$", file):
47
                classpath.append(libdir + "/" + file)
48
    return ':'.join(classpath)
49
50
#    -socketwait 12345
51
#    -stdout $APP_HOME/log/stdout.log
52
#    -stderr $APP_HOME/log/stderr.log
53
54
def readProcessId():
55
    f = open(PID_FILE, 'r')
56
    pid = int(f.readline())
57
    f.close()
58
    return pid
59
60
def isProgramRunning(pid):
61
    # Send a dummy signal to the process.  If it died, an exception is
62
    # thrown
63
    try:
64
        os.kill(pid, signal.SIGCONT)
65
        return 1
66
    except OSError:
67
        return 0
68
69
def usage():
70
    print >> sys.stderr, "Usage: %s {start|stop|restart}" % sys.argv[0]
71
72
def start():
73
    cwd = os.getcwd()
74
    if os.path.exists(PID_FILE):
75
        # Read the process id
76
        pid = readProcessId()
77
78
        if isProgramRunning(pid):
79
            print >> sys.stderr, '%s already started' % APP_NAME
80
            sys.exit(3)
81
82
    if not(os.path.exists(COMMAND)):
83
        print >> sys.stderr, '%s cannot be found' % COMMAND
84
        sys.exit(3)
85
86
    # Append program output to a log file
87
    l = open(LOG_FILE, 'a')
88
    orig_stderr = os.dup(sys.stderr.fileno())
89
    os.dup2(l.fileno(), sys.stdout.fileno())
90
    os.dup2(l.fileno(), sys.stderr.fileno())
91
92
    finfo = os.stat(COMMAND)[stat.ST_MODE]
93
    executable = stat.S_IMODE(finfo) & 0111
94
    if not(executable):
95
        sys.stderr = os.fdopen(orig_stderr, 'w')
96
        print >> sys.stderr, 'Cannot run %s, execute bit is missing' % COMMAND
97
        sys.exit(5)
98
99
    if APP_HOME:
100
        # Change current directory to APP_HOME
101
        os.chdir(APP_HOME)
102
103
    # Start program in the background
104
    pid = os.spawnv(os.P_NOWAIT, COMMAND, ARGS)
105
106
    # Wait a little
107
    time.sleep(.4)
108
    (unused_pid, status) = os.waitpid(pid, os.WNOHANG)
109
110
    # Check program exit status, if available
111
    if unused_pid != 0 and os.WIFEXITED(status):
112
        sys.stderr = os.fdopen(orig_stderr, 'w')
113
        print >> sys.stderr, 'Could not start %s.  Check %s for errors.' % (APP_NAME, LOG_FILE)
114
        sys.exit(2)
115
116
    # It's alive, so write down the process id
117
    os.chdir(cwd)
118
    f = open(PID_FILE, 'w')
119
    print >> f, pid
120
    f.close()
121
122
def warnNotRunning():
123
    if sys.argv[1] == "stop":
124
        print >> sys.stderr, '%s is not running' % APP_NAME
125
    else:
126
        print >> sys.stderr, 'Warning: %s was not running' % APP_NAME
127
128
def cleanup():
129
    os.unlink(PID_FILE)
130
131
def stop():
132
    if os.path.exists(PID_FILE):
133
        # Read the process id
134
        pid = readProcessId()
135
    else:
136
        warnNotRunning()
137
        return
138
139
    if not(isProgramRunning(pid)):
140
        warnNotRunning()
141
        cleanup()
142
        return
143
144
    # Terminate program
145
    os.kill(pid, signal.SIGTERM)
146
147
    while isProgramRunning(pid):
148
        time.sleep(.1)
149
150
    cleanup()
151
152
if __name__ == '__main__':
153
    LOG_FILE = "%%LOG_FILE%%"
154
    APP_NAME = "%%APP_NAME%%"
155
    APP_HOME = "%%APP_HOME%%"
156
    CONTROL_PROGRAM = "%%APP_NAME%%ctl"
157
    PID_FILE = "%%PID_FILE%%"
158
    COMMAND = "%%JAVA%%"
159
    ARGS = [COMMAND]
160
161
    if os.environ.has_key('JAVA_OPTS'):
162
        ARGS += os.environ['JAVA_OPTS'].split(" ")
163
164
    ARGS += [
165
        "-Dresin.home=%%APP_HOME%%",
166
        "com.caucho.server.http.HttpServer",
167
        "-conf", "%%PREFIX%%/etc/%%APP_NAME%%.xml"
168
        ]
169
170
    os.environ['JAVA_HOME'] = "%%JAVA_HOME%%"
171
    os.environ['CLASSPATH'] = classpath()
172
173
    if len(sys.argv) != 2:
174
        usage()
175
        sys.exit(1)
176
177
    if sys.argv[1] == "start":
178
        start()
179
180
    elif sys.argv[1] == "stop":
181
        stop()
182
183
    elif sys.argv[1] == "restart":
184
        stop()
185
        start()
186
187
    else:
188
        usage()
189
        sys.exit(1)
(-)./pkg-plist (+1 lines)
Lines 195-200 Link Here
195
%%APP_NAME%%/doc/java_tut/javadoc/package-list
195
%%APP_NAME%%/doc/java_tut/javadoc/package-list
196
%%APP_NAME%%/doc/java_tut/javadoc/resources/inherit.gif
196
%%APP_NAME%%/doc/java_tut/javadoc/resources/inherit.gif
197
%%APP_NAME%%/doc/java_tut/javadoc/stylesheet.css
197
%%APP_NAME%%/doc/java_tut/javadoc/stylesheet.css
198
%%APP_NAME%%/doc/java_tut/jndi-appconfig.xtp
198
%%APP_NAME%%/doc/java_tut/linux-boot.xtp
199
%%APP_NAME%%/doc/java_tut/linux-boot.xtp
199
%%APP_NAME%%/doc/java_tut/linux-init.xtp
200
%%APP_NAME%%/doc/java_tut/linux-init.xtp
200
%%APP_NAME%%/doc/java_tut/mail_form.xtp
201
%%APP_NAME%%/doc/java_tut/mail_form.xtp

Return to bug 77988