Create a service for JIRA on CentOS 5 or RHEL 5

logo-jiraAtlassian JIRA is a bug and issue tracker. Atlassian JIRA lets you priorities, assign, track, report and audit your ‘issues,’ whatever they may be — from software bugs and help-desk tickets to project tasks and change requests. After installing JIRA, on a CentOS 5.2 Linux installation, I wanted to automate the starting and stopping of JIRA by creating a service. I found a script that worked for me after a few minor configuration changes. Using gedit or any text editor, I created a file called jira.txt.

#!/bin/bash
#
# chkconfig: 2345 85 15
# description: jira
# processname: jira
# source function library
./etc/init.d/functions

JAVA_HOME="/usr/java/default"
JRE_HOME="/usr/java/default"
CATALINA_HOME="/usr/lib/jira/jira"

RETVAL=0

start() {
echo -n $"Starting jira services: "
./usr/lib/jira/jira/bin/catalina.sh start
RETVAL=$?
echo
}

stop() {
echo -n $"Shutting down jira services: "
./usr/lib/jira/jira/bin/catalina.sh stop
RETVAL=$?
echo
}

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

After creating the script. I saved the script jira.txt to the Desktop of the account I was using, root. Using terminal, I entered the following commands to create an automated service. These steps are taken from this source.

  • Move the file to /etc/init.d directory and rename it to just jira:
    # mv /root/Desktop/jira.txt /etc/init.d/jira
  • Change directory to /etc/init.d:
    # cd /etc/init.d
  • Make the file executable:
    # chmod +x jira
  • Add the file to the chkconfig list so that it will start at startup:
    # chkconfig --add jira

Note: Even after successfully entering the above commands, I was unable to execute the service through the GUI, I did get several errors. I rebooted the server (I don’t know if that was totally necessary) and noted that at boot the service started successfully. After logging in, I discovered I was able to use the GUI to start, stop, and restart the service. Also noted, the status is incorrect. I couldn’t figure out the correct code to fix that (minor) detail.

jira in action

To start the service manually.

# /etc/init.d/jira start

To stop the service manually.

# /etc/init.d/jira stop

To restart the service manually.

# /etc/init.d/jira restart

To see JIRA in action, http://xxx.xxx.xxx.xxx:8080