cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco as a Service

cbosdonnat
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to add alfresco as a service on a redhat server: ie: I'm writing a /etc/init.d/alfresco script. I'ld like to be sure that alfresco is fully started after running
/etc/init.d/alfresco start
because if it isn't the case, the stop action will fail. Is there any way to change alfresco startup to run it synchronously ?

Thanks for your help
2 REPLIES 2

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi,

This is the script I use:
#!/bin/sh
#
# Startup script for Alfresco
#
# chkconfig: 345 96 14
# description: Tomcat Servlet Engine running Alfresco
# processname: tomcat
# pidfile: /opt/alfresco/alfresco.pid
#

# User under which tomcat will run
TOMCAT_USER=root
JAVA_HOME=/opt/java/jdk

RETVAL=0

# start, debug, stop, and status functions
start() {
    # Start Tomcat in normal mode
    SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep 8005|wc -l`
    export JAVA_HOME=$JAVA_HOME
    if [ $SHUTDOWN_PORT -ne 0 ]; then
        echo "Alfresco already started"
    else
        echo "Starting alfresco…"
        sudo -u $TOMCAT_USER /opt/alfresco/alf_start.sh
        SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep 8005|wc -l`
        while [ $SHUTDOWN_PORT -eq 0 ]; do
            sleep 1
            SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep 8005|wc -l`
        done
        RETVAL=$?
        echo "Alfresco started"
        [ $RETVAL=0 ] && touch /var/lock/subsys/alfresco
    fi
}

stop() {
    SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep 8005|wc -l`
    export JAVA_HOME=$JAVA_HOME
    if [ $SHUTDOWN_PORT -eq 0 ]; then
        echo "Alfresco already stopped"
    else
        echo "Stopping alfresco…"
        sudo -u $TOMCAT_USER /opt/alfresco/alf_stop.sh
        SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep 8005|wc -l`
        done
        RETVAL=$?
        echo "Alfresco stopped"
        [ $RETVAL=0 ] && rm -f /var/lock/subsys/alfresco /opt/alfresco/alfresco.pid
    fi
}

status() {
    SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep 8005|wc -l`
    if [ $SHUTDOWN_PORT -eq 0 ]; then
}       echo "Alfresco stopped"
    else
        echo "Alfresco running"
    fi
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  status)
        status
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
esac

exit $RETVAL

Hope this helps,

–Aladdin

deetz
Champ in-the-making
Champ in-the-making
Anyone have a basic startup script?  I tried RivetLogic's but had problems and then noticed alf_start.sh and alf_stop.sh are possibly old or something.

I get an error "line 47: syntax error near unexpected token `done'" when I do try his script.