I'm trying to create a service on Centos 6, but it's executing on the startup console instead of in background, which means it never reaches the user interface - it just hangs on the startup display.
Here is the service:
#!/bin/bash
#
# run red5 server
#
# chkconfig: 5 70 30
# description: app server
# processname: red5
# Source function library.
. /etc/init.d/functions
RETVAL=0
prog="red5"
LOCKFILE=/var/lock/subsys/$prog
# Declare variables for red5 Server
ANALYTICS_DIR=/home/engineering/SVP/app-server
start() {
echo -n "Starting $prog: "
cd $ANALYTICS_DIR
daemon ./red5.sh
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
echo
return $RETVAL
}
stop() {
echo -n "Shutting down $prog: "
cd $ANALYTICS_DIR
nohup ./red5-stop.sh && success || failure
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
echo
return $RETVAL
}
status() {
echo "stub"
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
Here's the red5.sh script (which runs another script)
#!/bin/bash
if [ -z "$RED5_HOME" ]; then
export RED5_HOME=`pwd`;
fi
export JAVA_OPTS="${JAVA_OPTS} -Xms1g -Xmx1g -Xss256K"
LOG_OPTS="-DSERVER_LOGS=/var/opt/SVP/svp-server/log"
source ${RED5_HOME}/red5-start.sh
Here's red5-start.sh
#!/bin/bash
if [ -z "$RED5_HOME" ]; then
export RED5_HOME=`pwd`;
fi
P=":" # The default classpath separator
OS=`uname`
case "$OS" in
CYGWIN*|MINGW*) # Windows Cygwin or Windows MinGW
P=";" # Since these are actually Windows, let Java know
;;
Darwin*)
;;
*)
# Do nothing
;;
esac
echo "Running on " $OS
# JAVA options
# You can set JAVA_OPTS to add additional options if you want
JAVA_OPTS="$JAVA_OPTS -Xverify:none -XX:+TieredCompilation -XX:+UseBiasedLocking -XX:+UseParNewGC -XX:InitialCodeCacheSize=8m -XX:ReservedCodeCacheSize=32m -Dorg.terracotta.quartz.skipUpdateCheck=true"
# Set up logging options
LOGGING_OPTS="-Dlogback.ContextSelector=org.red5.logging.LoggingContextSelector -Dcatalina.useNaming=true"
# Set up security options
SECURITY_OPTS="-Djava.security.debug=failure"
# Set up MySQL encryption
export APP_ENC=encrypt
# Set up Java system property for location of the application server log files
export JAVA_OPTS="$LOGGING_OPTS $SECURITY_OPTS $JAVA_OPTS $LOG_OPTS"
if [ -z "$RED5_MAINCLASS" ]; then
export RED5_MAINCLASS=org.red5.server.Bootstrap
fi
# Jython options
JYTHON="-Dpython.home=lib"
#for JAVA in "${JAVA_HOME}/bin/java" "${JAVA_HOME}/Home/bin/java" "/usr/bin/java" "/usr/local/bin/java"
for JAVA in "${JAVA_HOME}/bin/java" "${JAVA_HOME}/Home/bin/java" "/usr/bin/java" "/usr/local/bin/java"
do
if
[ -x "$JAVA" ]
then
break
fi
done
export JAVA=/usr/bin/java
if [ ! -x "$JAVA" ]
then
break
fi
done
export JAVA=/usr/bin/java
if [ ! -x "$JAVA" ]
then
echo "Unable to locate Java. Please set JAVA_HOME environment variable."
exit
fi
export RED5_CLASSPATH="${RED5_HOME}/red5-service.jar${P}${RED5_HOME}/lib/mail.jar${P}${RED5_HOME}/conf${P}${CLASSPATH}"
# start Red5
echo "Starting Red5"
echo "JAVA is: $JAVA"
exec "$JAVA" "$JYTHON" -Dred5.root="${RED5_HOME}" $JAVA_OPTS -cp "${RED5_CLASSPATH}" "$RED5_MAINCLASS" $RED5_OPTS
Is the problem the fact that the service is calling another script?
Do I need to run the red5-start.sh as a deamon from red5? I would prefer not to do that, and I know this has worked before as a service without having to do that. It's just that I don't have a copy of the service that was originally set up, so I'm trying to figure out how it worked.