The following should work on centos/redhat, don't forget to edit the paths,
user, and java options for your environment. You can use chkconfig to add it
to your startup.

Note, this script assumes that the Solr webapp is configured using JNDI in a
tomcat context fragment. If not you will need to add something like
-Dsolr.solr.home=/solr/home to the JAVA_OPTS line.

Colin.

#!/bin/sh
# chkconfig: 345 99 1
# description: Tomcat6 service
# processname: java

. /etc/init.d/functions

my_log_message()
    {
        ACTION=$1
        shift

        case "$ACTION" in
            success)
                echo -n $*
                success "$*"
                echo
                ;;
            failure)
                echo -n $*
                failure "$*"
                echo
                ;;
            warning)
                echo -n $*
                warning "$*"
                echo
                ;;
            *)
                ;;
        esac
    }
    log_success_msg()
    {
        my_log_message success "$*"
    }
    log_failure_msg()
    {
        my_log_message failure "$*"
    }
    log_warning_msg()
    {
        my_log_message warning "$*"
    }

export JAVA_HOME=/usr/java/default
export TOMCAT_USER=solr
export CATALINA_HOME=/opt/solr/production/tomcat6
export CATALINA_PID=$CATALINA_HOME/bin/tomcat6.pid
JAVA_OPTS="-server -Xms6G -Xmx6G -XX:+UseConcMarkSweepGC"
export JAVA_OPTS

[ -d "$CATALINA_HOME" ] || { echo "Tomcat requires $CATALINA_HOME."; exit 1;
}

case $1 in

    start|stop|run) 
    if su $TOMCAT_USER bash -c "$CATALINA_HOME/bin/catalina.sh $1"; then
        log_success_msg "Tomcat $1 successful"
        [ $1 == "stop" ] && rm -f $CATALINA_PID
    else
        log_failure_msg "Error in Tomcat $1: $?"
    fi
    ;;

    restart)
    $0 start
    $0 stop
    ;;

    status)
    if [ -f "$CATALINA_PID" ]; then
        read kpid < "$CATALINA_PID"
        if ps --pid $kpid 2>&1 1>/dev/null; then
            echo "$0 is already running at ${kpid}"
        else
            echo "$CATALINA_PID found, but $kpid is not running"
        fi
        unset kpid
    else
        echo "$0 is stopped"
    fi
    ;;

esac   
exit 0


> -----Original Message-----
> From: Sixten Otto [mailto:six...@sfko.com]
> Sent: Tuesday, June 08, 2010 3:49 PM
> To: solr-user@lucene.apache.org
> Subject: Re: Tomcat startup script
> 
> On Tue, Jun 8, 2010 at 11:00 AM, K Wong <wongo...@gmail.com> wrote:
> > Okay. I've been running multicore Solr 1.4 on Tomcat 5.5/OpenJDK 6
> > straight out of the centos repo and I've not had any issues. We're
> not
> > doing anything wild and crazy with it though.
> 
> It's nice to know that the wiki's advice might be out of date. That
> doesn't really help me with my immediate problem (lacking the script
> the wiki is trying to provide), though, unless I want to rip out what
> I've got and start over. :-/
> 
> Sixten



Reply via email to