I'm trying to write a startup script for confluence on Ubuntu server 11.10. I tried the 2 scripts below:
script 1:
#!/bin/bash
### BEGIN INIT INFO
# Provides: confluence
# Required-Start: $local_fs $network mysql
# Should-Start:
# Required-Stop: $local_fs $network mysql
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start Confluence - The Enterprise Wiki
### END INIT INFO
## START OF CONFIGURATION
# Name of the user to run as
USER=prisa
# Location of application's bin directory
CATALINA_HOME=/opt/confluence
# Minimum Tomcat heap space (for performance reasons on high load,
# this value should be the same as MAX_HEAP)
MIN_HEAP=1024m
# Maximum Tomcat heap space
MAX_HEAP=1024m
# This should be roughly 40% of your MAX_HEAP
EDEN_SIZE=400m
# Additional options
# see http://confluence.atlassian.com/display/DOC/Recognised+System+Properties for a complete list of options
EXTRA_OPTS=
# Sleep time in seconds, only even numbers
WAIT=10
## TUNING OPTIONS
#
# Most of these optimizations come from
# http://java.sun.com/performance/reference/whitepapers/tuning.html
# http://confluence.atlassian.com/display/DOC/Garbage+Collector+Performance+Issues
#
# No Tuning per default
#TUN_EXTRA_OPTS=
# This setting enables the latest performance optimizations from the Java team
# Be cautious, as this option enables/disables other options and is subject to changes
# from release to release
# In general, this has proven to give Confluence a decent performance boost
#TUN_EXTRA_OPTS=$TUN_EXTRA_OPTS -XX:+AggressiveOpts
# Escape Analysis
#TUN_EXTRA_OPTS=$TUN_EXTRA_OPTS -XX:-DoEscapeAnalysis
# Enable this if you're running a small instance with 512MB - 768MB max heap
#TUN_EXTRA_OPTS=$TUN_EXTRA_OPTS -XX:+UseSerialGC -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:NewRatio=8
# If JDK 6 Update 20 or later is installed, enable this
#TUN_EXTRA_OPTS=$TUN_EXTRA_OPTS -XX:+OptimizeStringConcat
# If you run on an Intel CPU with 'Quick Path Interconnect', then enable this
#TUN_EXTRA_OPTS=$TUN_EXTRA_OPTS -XX:+UseNUMA
#
## END OF TUNING OPTIONS
## END OF CONFIGURATION
# Reset everything
true
export JRE_HOME=$CATALINA_HOME/jre
# Write a PID file
export CATALINA_PID=$CATALINA_HOME/work/catalina.pid
# These are our Java parameters
export JAVA_OPTS=-server -Xms$MIN_HEAP -Xmx$MAX_HEAP -XX:NewSize=$EDEN_SIZE -XX:MaxPermSize=256m -Djava.awt.headless=true $EXTRA_OPTS $TUN_EXTRA_OPTS
# Clear the setenv.sh if it isn't empty (because we set the environment via JAVA_OPTS above)
if -s $CATALINA_HOME/bin/setenv.sh ; then
cat /dev/null > $CATALINA_HOME/bin/setenv.sh
fi
APP=confluence
case $1 in
start)
if -e $CATALINA_PID ; then
$0 status &>/dev/null
ret=$?
if $ret = 1 ; then
echo Warning: found stale pidfile (unclean shutdown?)
rm -f $CATALINA_PID
elif $ret = 0 ; then
echo $APP is already running ($CATALINA_PID)
exit $ret
fi
fi
echo Starting $APP
cd $CATALINA_HOME
/bin/su $USER -c $CATALINA_HOME/bin/startup.sh >/dev/null
;;
stop)
pid=$(<$CATALINA_PID)
echo Shutting down $APP
cd $CATALINA_HOME
/bin/su $USER -c $CATALINA_HOME/bin/shutdown.sh >/dev/null
sleep $WAIT
$0 status &>/dev/null
if -f $CATALINA_PID ; then
echo $APP didn't stop within $WAIT seconds, forcing stop...
kill -TERM $pid 2>/dev/null
sleep $(( $WAIT/5 ))
$0 status &>/dev/null
ret=$?
rm -f $CATALINA_PID
if $ret = 0 ; then
# not terminated yet, we force it
echo ($app still running, killing...)
kill -KILL $pid 2>/dev/null
fi
fi
;;
restart)
$0 stop
$0 start
;;
force-reload)
echo Force reload not supported
;;
status)
echo -n $APP is
if ! -f $CATALINA_PID ; then
# not running
echo not running
exit 3
elif -s $CATALINA_PID -a -d /proc/$(<$CATALINA_PID) ; then
# running
echo running
:
else
# stale pid file
echo dead
exit 1
fi
;;
*)
echo Usage: /etc/init.d/$APP {start|restart|stop|status}
exit 1
;;
esac
exit 0
script 2
--------
#!/bin/bash
### BEGIN INIT INFO
# Provides: confluence
# Required-Start: $local_fs $network mysql
# Should-Start:
# Required-Stop: $local_fs $network mysql
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start Confluence - The Enterprise Wiki
### END INIT INFO
# Define some variables
# Name of app ( JIRA, Confluence, etc )
APP=confluence
# Name of the user to run as
USER=prisa
# Location of application's bin directory
CATALINA_HOME=/opt/confluence
# Location of Java JDK
export JAVA_HOME=/usr/lib/jvm/java-6-oracle
case $1 in
# Start command
start)
echo Starting $APP
/bin/su -m $USER -c $CATALINA_HOME/bin/start-confluence.sh &> /dev/null
;;
# Stop command
stop)
echo Stopping $APP
/bin/su -m $USER -c $CATALINA_HOME/bin/shutdown.sh &> /dev/null
echo $APP stopped successfully
;;
# Restart command
restart)
$0 stop
sleep 5
$0 start
;;
*)
echo Usage: /etc/init.d/$APP {start|restart|stop}
exit 1
;;
esac
exit 0
I tried script 1, when it fails I removed and tried script 2. script 2 seems fine but then there's no catalina pid generated, so I guess it is not started.
Please I need help with this. We are currently in production and can't access confluence.
Thanks
Hi Kayode
I'd suggest to review the all the settings using the official script as a guideline:
https://confluence.atlassian.com/display/DOC/Start+Confluence+Automatically+on+Linux
Probably, you're forgetting to call some Tomcat/JAVA function.
Cheers,
Paulo Renato
Hi Kayode:
Great script!
It seems to be working fine. I adapted here on Ubuntu and I could start and stop my confluence instance just fine.
1) Check if the path to the scripts are ok:
/opt/confluence/bin/start-confluence.sh
/opt/confluence/bin/stop-confluence.sh
2) Check if the your Java path is correct
export JAVA_HOME=/usr/lib/jvm/java-6-oracle
(you can comment this line or change your JAVA_HOME to /usr/lib/jvm)
3) Check if the USER prisa can actually start confluence. To do that login as that user and see if he is able to manually start it:
root@yourmachine:~# su prisa
prisa@yourmachine:~$ ls /opt/confluence/bin/
prisa@yourmachine:/opt/confluence/bin/$ ./start-confluence.sh
I used root to start my confluence and it started just fine.
4) Try to remove the &> /dev/null from the following lines:
/bin/su -m $USER -c $CATALINA_HOME/bin/start-confluence.sh &> /dev/null
/bin/su -m $USER -c $CATALINA_HOME/bin/shutdown.sh &> /dev/null
So you'll be able to see if the confluence is starting or not.
5) And the last advice:
To see if confluence is actuallt starting, check the process is running.
# ps aux | grep confluence
Hope it helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kayode:
The script that worked fine for me was the second (script2.txt).
I made some changes to my environment.
Attached as txt for security reasons.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks.
The line `cat /dev/null > $CATALINA_HOME/bin/setenv.sh` was the major problem in script 1. It cleared entries in setenv.sh. Thanks to Ryan Goodwin for this.
Which of the scripts worked for you Bruna?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.