Auto start Atlassian Fisheye/Crucible on CentOs

In this article I’ll explain how to auto start Fisheye/Crucible. Earlier today I wrote an article about how to auto start Jira, Crowd and Confluence using a dedicated (non root) user after rebooting the system. Jira, Crowd and Confluence have Apache Tomcat ‘built in’. Unfortunately there are some differences between the way how Atlassian products are set up. Fisheye does not come with Tomcat, which means it is a bit more difficult to get things going.

The first problem we encountered was binding to port 80. It is quite easy to do this by editing the config.xml or using the admin console. However, you will run into the issue that only root users can use port 80. So it is best to leave the default port binding at 8060 and use a different approach with the iptables command.

First make sure that all ports that are required have been opened up in the firewall. Open port 80, 8060 and 8059 (control port).

system-config-securitylevel

Now add a ‘prerouting rule’ and save it. This rule will redirect all traffic from port 80 to port 8060. So you can use the URL http://fisheye and do not need to specify port 8060 (http://fisheye:8060). Use these two commands (first command is split in two lines, it is one line!).

iptables -t nat -A PREROUTING -p tcp –dport 80 -j REDIRECT –to-port 8060

/sbin/service iptables save

That taken care off we can now create our dedicated user and grant this user the ownership of the relevant folder (change folder name to match your own situation).

useradd -m fisheye

chown -R fisheye /opt/fecru-2.2.0

As we will add a Fisheye service we now create the service script. If you copy/paste be aware that some extra line-feeds may have been added, remove those. The script has been created using various sources and surely can be improved, I am no Linux guru!

nano /etc/init.d/fisheye

This is the content:

#!/bin/bash

# Crucible/Fisheye startup script

# chkconfig: 345 90 90

# description: Atlassian Crucible

CRUCIBLE_USER=fisheye

CRUCIBLE_HOME=/opt/fecru-2.2.0/bin

RETVAL=0

prog=crucibled

pidfile=/var/lock/subsys/crucibled

start() {

echo -n $”Starting $prog: “

if [ “x$USER” != “x$CRUCIBLE_USER” ]; then

su – $CRUCIBLE_USER -c “$CRUCIBLE_HOME/fisheyectl.sh start”

else

$CRUCIBLE_HOME/fisheyectl.sh start

fi

echo

[ $RETVAL = 0 ] && touch $pidfile

sleep 3

return $RETVAL

}

stop() {

echo -n $”Shutting down $prog: “

if [ “x$USER” != “x$CRUCIBLE_USER” ]; then

su – $CRUCIBLE_USER -c “$CRUCIBLE_HOME/fisheyectl.sh stop”

else

$CRUCIBLE_HOME/fisheyectl.sh stop

fi

echo

rm -f $pidfile

return $RETVAL

}

case “$1” in

start)

start

;;

stop)

stop

;;

restart)

stop

sleep 10

start

;;

*)

echo “Usage: $0 {start|stop|restart}”

esac

exit 0

Now make the script executable.

chmod +x /etc/init.d/fisheye

Then add the script as a service.

chkconfig –add fisheye

chkconfig fisheye on

After this has been done you can manually start or stop the service by using these commands:

service fisheye stop

service fisheye start

If you dare issue a reboot command and check if the application comes back up after rebooting (please make sure that your database is auto started as well). If you encounter a problem then you could check the log files in application its var folder. Maybe an extra line-feed was added to the script when you copied and pasted it (double check).

If the application is running then you should see it running under its own user:

ps -ef | grep java

Good luck! Please comment if you know ways to improve.

Leave a Reply

Your email address will not be published. Required fields are marked *