[RPM Installer] Generic start/stop shell script
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Directory Project > [RPM Installer] Generic start/stop shell script




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    [RPM Installer] Generic start/stop shell script  
Ole Ersoy


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-22-07 06:11 AM

I've tried to reduce our start/stop shell script to a minimum needed
for RPM (I think Solaris, Mac, *NIX in general).

I still need to test it out of coarse, but I thought I'd throw it out
here in case anyone has a chance to kick it.

Just substitute apacheds for ${name} (It's a pseudo template - The fina
l
one will be a jet template....)


#!/bin/bash
#
# chkconfig: - 91 35
# description: Starts and stops ${name} server.
#
# Shell script to start/stop ${name}
# If you want to change ${name} service settings please modify the
server.xml
# file.
#


# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
fi

# Source networking configuration.
if [ -f /etc/sysconfig/network ] ; then
. /etc/sysconfig/network
fi

# Check that networking is up.
if [ ! -z "$NETWORKING" ] ; then
if [ "$NETWORKING" = "no" ] ; then
exit 0
fi
fi

prog=$"${name} server"
StringUtils.toUpperCase(${name})_HOME=/usr/share/${name}-${ve
rsion}
#So for ApacheDS this would be
# APACHEDS_HOME = /usr/share/apacheds-1.0.1

if [ -z "$JAVA_HOME" ] ; then
echo "Error: JAVA_HOME environment variable is not set."
echo "You will need to set the JAVA_HOME environment variable to"
echo "the the path of the root Java  installation directory."
echo "See the installation guide for further instructions."
else
echo JAVA_HOME=$JAVA_HOME
fi


DAEMON_HOME=$APACHEDS_HOME/bin
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar

#The statement below will probably be shortened to
#$DAEMON_HOME/bootstrapper.jar
#when we figure out how to use the daemon and logger from
/usr/share/java instead.

CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar:$
DAEMON_HOME/daemon.jar
echo CLASSPATH=$CLASSPATH
StringUtils.toUpperCase(${name})_USER=$USER

TMP_DIR=/var/tmp/${name}-${version}
PID_FILE=/var/run/${name}-${version}/server.pid

cd $StringUtils.toUpperCase(${name})_HOME

case "$1" in
start)
#
# Start apacheds
#
echo -n $"Starting $prog: "
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0

$DAEMON_HOME/apacheds \
-user $StringUtils.toUpperCase(${name})_USER \
-home $JAVA_HOME \
-Djava.io.tmpdir=$TMP_DIR \

-Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.pro
perties\
-Xms384m -Xmx384m \
-pidfile $PID_FILE \
-outfile /var/log/${name}-${version}/${name}-stdout.log \
-errfile /var/log/${name}-${version}/${name}-stderr.log \
-cp $CLASSPATH \
org.apache.directory.daemon.JsvcBootstrapper \
$StringUtils.toUpperCase(${name})_HOME start

[ "$RETVAL" -eq 0 ] && success $"apacheds server startup" || \
failure $"${name} server start"
echo
if [ -d /var/lock/subsys ] ; then
[ "$RETVAL" -eq 0 ] && touch
/var/${name}-${version}/apacheds.lock
fi

exit $RETVAL
;;

stop)
#
# Stop ${name}
#
echo -n $"Shutting down $prog: "
RETVAL=0

$DAEMON_HOME/${name} \
-stop \
-pidfile $PID_FILE \

-Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.pro
perties\
org.apache.directory.daemon.JsvcBootstrapper stop

[ "$RETVAL" -eq 0 ] && success $"apacheds server shutdown" || \
failure $"apacheds server shutdown"
echo
if [ -d /var/lock/subsys/apacheds ] ; then
[ "$RETVAL" -eq 0 ] && rm $APACHEDS_HOME/var/apacheds.lock
fi

exit $RETVAL
;;

debug)
#
# Debug ${name}
#
echo -n $"Starting $prog in debug mode: "
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0

if [ -z "$2" ] ; then
echo
echo  ========================================
================
echo "Warning: the debug port is not set. Using 5005 default."
echo  ========================================
================
echo
DEBUG_PORT=5005
else
DEBUG_PORT="$2"
fi

$JAVA_HOME/bin/java\

-Dlog4j.configuration=file://$StringUtils.toUpperCase(${name})_HOME/con
f/log4j.properties\
-Xms384m -Xmx384m \
-Dcom.sun.management.jmxremote \
-Xdebug -Xnoagent -Djava.compiler=NONE\
- Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\
-jar $DAEMON_HOME/bootstrapper.jar \
$StringUtils.toUpperCase(${name})_HOME start
;;

*)
echo "Usage ${name} [start|stop|debug]"
exit 1;;
esac









[ Post a follow-up to this message ]



    Re: [RPM Installer] Generic start/stop shell script  
Alex Karasulu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-27-07 06:11 PM

We might want to look at making some things like the min max heap sizes
variable with defaults.  However this we can do
later after getting everything working.

Alex


On 3/21/07, Ole Ersoy <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> I've tried to reduce our start/stop shell script to a minimum needed
> for RPM (I think Solaris, Mac, *NIX in general).
>
> I still need to test it out of coarse, but I thought I'd throw it out
> here in case anyone has a chance to kick it.
>
> Just substitute apacheds for ${name} (It's a pseudo template - The fi
nal
> one will be a jet template....)
>
>
> #!/bin/bash
> #
> # chkconfig: - 91 35
> # description: Starts and stops ${name} server.
> #
> # Shell script to start/stop ${name}
> # If you want to change ${name} service settings please modify the
> server.xml
> # file.
> #
>
>
> # Source function library.
> if [ -f /etc/init.d/functions ] ; then
>     . /etc/init.d/functions
> fi
>
> # Source networking configuration.
> if [ -f /etc/sysconfig/network ] ; then
>     . /etc/sysconfig/network
> fi
>
> # Check that networking is up.
> if [ ! -z "$NETWORKING" ] ; then
>      if [ "$NETWORKING" = "no" ] ; then
>           exit 0
>      fi
> fi
>
> prog=$"${name} server"
> StringUtils.toUpperCase(${name})_HOME=/usr/share/${name}-${
version}
> #So for ApacheDS this would be
> # APACHEDS_HOME = /usr/share/apacheds-1.0.1
>
> if [ -z "$JAVA_HOME" ] ; then
> echo "Error: JAVA_HOME environment variable is not set."
> echo "You will need to set the JAVA_HOME environment variable to"
> echo "the the path of the root Java  installation directory."
> echo "See the installation guide for further instructions."
> else
> echo JAVA_HOME=$JAVA_HOME
> fi
>
>
> DAEMON_HOME=$APACHEDS_HOME/bin
> CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
>
> #The statement below will probably be shortened to
> #$DAEMON_HOME/bootstrapper.jar
> #when we figure out how to use the daemon and logger from
> /usr/share/java instead.
>
>
> CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar
:$DAEMON_HOME/daemon.jar
> echo CLASSPATH=$CLASSPATH
> StringUtils.toUpperCase(${name})_USER=$USER
>
> TMP_DIR=/var/tmp/${name}-${version}
> PID_FILE=/var/run/${name}-${version}/server.pid
>
> cd $StringUtils.toUpperCase(${name})_HOME
>
> case "$1" in
> start)
>    #
>    # Start apacheds
>    #
>    echo -n $"Starting $prog: "
>    ulimit -S -c 0 >/dev/null 2>&1
>    RETVAL=0
>
>    $DAEMON_HOME/apacheds \
>    -user $StringUtils.toUpperCase(${name})_USER \
>    -home $JAVA_HOME \
>    -Djava.io.tmpdir=$TMP_DIR \
>
> -Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.p
roperties\
>    -Xms384m -Xmx384m \
>    -pidfile $PID_FILE \
>    -outfile /var/log/${name}-${version}/${name}-stdout.log 
\
>    -errfile /var/log/${name}-${version}/${name}-stderr.log 
\
>    -cp $CLASSPATH \
>    org.apache.directory.daemon.JsvcBootstrapper \
>    $StringUtils.toUpperCase(${name})_HOME start
>
>    [ "$RETVAL" -eq 0 ] && success $"apacheds server startup" || \
>         failure $"${name} server start"
>    echo
>    if [ -d /var/lock/subsys ] ; then
>           [ "$RETVAL" -eq 0 ] && touch
> /var/${name}-${version}/apacheds.lock
>    fi
>
>    exit $RETVAL
>    ;;
>
> stop)
>    #
>    # Stop ${name}
>    #
>    echo -n $"Shutting down $prog: "
>    RETVAL=0
>
>    $DAEMON_HOME/${name} \
>    -stop \
>    -pidfile $PID_FILE \
>
> -Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.p
roperties\
>    org.apache.directory.daemon.JsvcBootstrapper stop
>
>     [ "$RETVAL" -eq 0 ] && success $"apacheds server shutdown" || \
>          failure $"apacheds server shutdown"
>     echo
>     if [ -d /var/lock/subsys/apacheds ] ; then
>            [ "$RETVAL" -eq 0 ] && rm $APACHEDS_HOME/var/apacheds.lock
>     fi
>
>    exit $RETVAL
>    ;;
>
> debug)
>    #
>    # Debug ${name}
>    #
>    echo -n $"Starting $prog in debug mode: "
>    ulimit -S -c 0 >/dev/null 2>&1
>    RETVAL=0
>
>    if [ -z "$2" ] ; then
>      echo
>      echo  ========================================
================
>      echo "Warning: the debug port is not set. Using 5005 default."
>      echo  ========================================
================
>      echo
>      DEBUG_PORT=5005
>    else
>      DEBUG_PORT="$2"
>    fi
>
>    $JAVA_HOME/bin/java\
>
> -Dlog4j.configuration=file://$StringUtils.toUpperCase
> (${name})_HOME/conf/log4j.properties\
>    -Xms384m -Xmx384m \
>    -Dcom.sun.management.jmxremote \
>    -Xdebug -Xnoagent -Djava.compiler=NONE\
>    - Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\
>    -jar $DAEMON_HOME/bootstrapper.jar \
>    $StringUtils.toUpperCase(${name})_HOME start
>    ;;
>
> *)
>    echo "Usage ${name} [start|stop|debug]"
>    exit 1;;
> esac
>
>
>
>






[ Post a follow-up to this message ]



    Re: [RPM Installer] Generic start/stop shell script  
Ole Ersoy


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-28-07 06:11 AM

Yeah - Would be nice if the server.xml file could contain default
alternatives.

Anyone know if we can inject min/max heap size parameters into the JVM
post startup?

Thanks,
- Ole


Alex Karasulu wrote:
> We might want to look at making some things like the min max heap
> sizes variable with defaults.  However this we can do
> later after getting everything working.
>
> Alex
>
>
> On 3/21/07, *Ole Ersoy* <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>
>     I've tried to reduce our start/stop shell script to a minimum needed
>     for RPM (I think Solaris, Mac, *NIX in general).
>
>     I still need to test it out of coarse, but I thought I'd throw it out
>     here in case anyone has a chance to kick it.
>
>     Just substitute apacheds for ${name} (It's a pseudo template - Th
e
>     final
>     one will be a jet template....)
>
>
>     #!/bin/bash
>     #
>     # chkconfig: - 91 35
>     # description: Starts and stops ${name} server.
>     #
>     # Shell script to start/stop ${name}
>     # If you want to change ${name} service settings please modify th
e
>     server.xml
>     # file.
>     #
>
>
>     # Source function library.
>     if [ -f /etc/init.d/functions ] ; then
>         . /etc/init.d/functions
>     fi
>
>     # Source networking configuration.
>     if [ -f /etc/sysconfig/network ] ; then
>         . /etc/sysconfig/network
>     fi
>
>     # Check that networking is up.
>     if [ ! -z "$NETWORKING" ] ; then
>          if [ "$NETWORKING" = "no" ] ; then
>               exit 0
>          fi
>     fi
>
>     prog=$"${name} server"
>     StringUtils.toUpperCase(${name})_HOME=/usr/share/${name}-$&#
123;version}
>     #So for ApacheDS this would be
>     # APACHEDS_HOME = /usr/share/apacheds-1.0.1
>
>     if [ -z "$JAVA_HOME" ] ; then
>     echo "Error: JAVA_HOME environment variable is not set."
>     echo "You will need to set the JAVA_HOME environment variable to"
>     echo "the the path of the root Java  installation directory."
>     echo "See the installation guide for further instructions."
>     else
>     echo JAVA_HOME=$JAVA_HOME
>     fi
>
>
>     DAEMON_HOME=$APACHEDS_HOME/bin
>     CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
>
>     #The statement below will probably be shortened to
>     #$DAEMON_HOME/bootstrapper.jar
>     #when we figure out how to use the daemon and logger from
>     /usr/share/java instead.
>
>     CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger
.jar:$DAEMON_HOME/daemon.jar
>
>     echo CLASSPATH=$CLASSPATH
>     StringUtils.toUpperCase(${name})_USER=$USER
>
>     TMP_DIR=/var/tmp/${name}-${version}
>     PID_FILE=/var/run/${name}-${version}/server.pid
>
>     cd $StringUtils.toUpperCase(${name})_HOME
>
>     case "$1" in
>     start)
>        #
>        # Start apacheds
>        #
>        echo -n $"Starting $prog: "
>        ulimit -S -c 0 >/dev/null 2>&1
>        RETVAL=0
>
>        $DAEMON_HOME/apacheds \
>        -user $StringUtils.toUpperCase(${name})_USER \
>        -home $JAVA_HOME \
>        -Djava.io.tmpdir=$TMP_DIR \
>
>     -Dlog4j.configuration=file://etc/conf/${name}-${version}/log
4j.properties\
>        -Xms384m -Xmx384m \
>        -pidfile $PID_FILE \
>        -outfile /var/log/${name}-${version}/${name}- stdout
.log \
>        -errfile /var/log/${name}-${version}/${name}-stderr.
log \
>        -cp $CLASSPATH \
>        org.apache.directory.daemon.JsvcBootstrapper \
>        $StringUtils.toUpperCase(${name})_HOME start
>
>        [ "$RETVAL" -eq 0 ] && success $"apacheds server startup" || \
>             failure $"${name} server start"
>        echo
>        if [ -d /var/lock/subsys ] ; then
>               [ "$RETVAL" -eq 0 ] && touch
>     /var/${name}-${version}/apacheds.lock
>        fi
>
>        exit $RETVAL
>        ;;
>
>     stop)
>        #
>        # Stop ${name}
>        #
>        echo -n $"Shutting down $prog: "
>        RETVAL=0
>
>        $DAEMON_HOME/${name} \
>        -stop \
>        -pidfile $PID_FILE \
>
>     -
>     Dlog4j.configuration=file://etc/conf/${name}-${version}/log4
j.properties\
>        org.apache.directory.daemon.JsvcBootstrapper stop
>
>         [ "$RETVAL" -eq 0 ] && success $"apacheds server shutdown" || 
\
>              failure $"apacheds server shutdown"
>         echo
>         if [ -d /var/lock/subsys/apacheds ] ; then
>                [ "$RETVAL" -eq 0 ] && rm $APACHEDS_HOME/var/apacheds.l
ock
>         fi
>
>        exit $RETVAL
>        ;;
>
>     debug)
>        #
>        # Debug ${name}
>        #
>        echo -n $"Starting $prog in debug mode: "
>        ulimit -S -c 0 >/dev/null 2>&1
>        RETVAL=0
>
>        if [ -z "$2" ] ; then
>          echo
>          echo  ========================================
================
>          echo "Warning: the debug port is not set. Using 5005 default."
>          echo  ========================================
================
>          echo
>          DEBUG_PORT=5005
>        else
>          DEBUG_PORT="$2"
>        fi
>
>        $JAVA_HOME/bin/java\
>
>     -Dlog4j.configuration=file://$StringUtils.toUpperCase(${name})_HO
ME/conf/log4j.properties\
>        -Xms384m -Xmx384m \
>        -Dcom.sun.management.jmxremote \
>        -Xdebug -Xnoagent -Djava.compiler=NONE\
>
>     - Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\
>        -jar $DAEMON_HOME/bootstrapper.jar \
>        $StringUtils.toUpperCase(${name})_HOME start
>        ;;
>
>     *)
>        echo "Usage ${name} [start|stop|debug]"
>        exit 1;;
>     esac
>
>
>
>







[ Post a follow-up to this message ]



    Re: [RPM Installer] Generic start/stop shell script  
Alex Karasulu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-29-07 06:11 AM

Post startup?  Hmmm I don't think so since these parameters are needed to
initialize the
different memory pools for various memory models.  However I could be wrong.

Regards,
Alex


On 3/28/07, Ole Ersoy <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> Yeah - Would be nice if the server.xml file could contain default
> alternatives.
>
> Anyone know if we can inject min/max heap size parameters into the JVM
> post startup?
>
> Thanks,
> - Ole
>
>
> Alex Karasulu wrote: 
> out 
> CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar
:$DAEMON_HOME/daemon.jar 
> Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.pr
operties\ 
> Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.pr
operties\ 
> $APACHEDS_HOME/var/apacheds.lock 
> (${name})_HOME/conf/log4j.properties\ 
> - Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\ 
>
>






[ Post a follow-up to this message ]



    Re: [RPM Installer] Generic start/stop shell script  
Ole Ersoy


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-29-07 06:11 AM

I wonder if this might fix things?

http://jakarta.apache.org/commons/launcher/

It says it could be used to pass JVM arguments post startup.

So if that's the case maybe we can set the
-Xmx and -Xms parameters in the configuration
file...and alles gut.

Has anyone played with this?

Cheers,
- Ole




Alex Karasulu wrote:
> Post startup?  Hmmm I don't think so since these parameters are needed
> to initialize the
> different memory pools for various memory models.  However I could be
> wrong.
>
> Regards,
> Alex
>
>
> On 3/28/07, *Ole Ersoy* <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>
>     Yeah - Would be nice if the server.xml file could contain default
>     alternatives.
>
>     Anyone know if we can inject min/max heap size parameters into the
>     JVM
>     post startup?
>
>     Thanks,
>     - Ole
>
>
>     Alex Karasulu wrote: 
>     <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>     minimum needed 
>     throw it out 
>     - The 
>     modify the 
>     (${name})_HOME=/usr/share/${name}-${version} 
>     variable to" 
>     CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger
.jar:$DAEMON_HOME/daemon.jar
> 
>     -Dlog4j.configuration=file://etc/conf/${name}-${version}/log
4j.properties\ 
>     || \ 
>     Dlog4j.configuration=file://etc/conf/${name}-${version}/log4
j.properties\ 
>     shutdown" || \ 
>     $APACHEDS_HOME/var/apacheds.lock 
>      ========================================
================ 
>     default." 
>      ========================================
================ 
>     -Dlog4j.configuration=file://$StringUtils.toUpperCase(${name})_HO
ME/conf/log4j.properties\
> 
>     - Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\ 
>
>







[ Post a follow-up to this message ]



    Re: [RPM Installer] Generic start/stop shell script  
Alex Karasulu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-29-07 06:11 AM

No I have not tried it but I'm wondering if this is a launcher for a class
and not the jvm.  It sounds like it's more like the daemon bootstrapper
code.

However give it a try and let me know I could be totally wrong about it.
Just guessing from past history playing with the Tomcat launcher code while
formulating the daemon bootstrappers.  There's a lot that's borrowed from
there I think if this launcher thingy is what I think it is.

Alex


On 3/28/07, Ole Ersoy <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> I wonder if this might fix things?
>
> http://jakarta.apache.org/commons/launcher/
>
> It says it could be used to pass JVM arguments post startup.
>
> So if that's the case maybe we can set the
> -Xmx and -Xms parameters in the configuration
> file...and alles gut.
>
> Has anyone played with this?
>
> Cheers,
> - Ole
>
>
>
>
> Alex Karasulu wrote: 
> CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar
:$DAEMON_HOME/daemon.jar 
> Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.pr
operties\ 
> Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.pr
operties\ 
> (${name})_HOME/conf/log4j.properties\ 
> - Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\ 
>
>






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:41 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register