Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bitbucket Server Init Script - Status Problems

Derek Sheeman
Contributor
August 7, 2017 edited

I have taken the init.d script documented here 

https://confluence.atlassian.com/bitbucketserver/running-bitbucket-server-as-a-linux-service-776640157.html

And set it up to run my bitbucket application.  It stops and starts without any troubles, but the status command always throws an error:

[ec2-user@atl-bitbucket ~]$ sudo service atlbitbucket status
/etc/init.d/atlbitbucket: line 116: status_of_proc: command not found

After a little digging I went and verified rhel-lsb was installed and is at version 4.0.

I did also verify that the PIDFILE is being created in the defined location.

The application is running on an AWS linux instance.

I have placed my current version of the init script below, if anyone has experienced this problem before or sees a glaring error in the status segment that I'm missing, please help.

 

#! /bin/sh

### BEGIN INIT INFO
# Provides: bitbucket
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Initscript for Atlassian Bitbucket Server
# Description: Automatically start Atlassian Bitbucket Server when the system starts up.
# Provide commands for manually starting and stopping Bitbucket Server.
### END INIT INFO

# Adapt the following lines to your configuration
# RUNUSER: The user to run Bitbucket Server as.
RUNUSER=atlbitbucket

# BITBUCKET_INSTALLDIR: The path to the Bitbucket Server installation directory
BITBUCKET_INSTALLDIR="/opt/atlassian/current"

# BITBUCKET_HOME: Path to the Bitbucket home directory
BITBUCKET_HOME="/opt/atlassian/home"

# ==================================================================================
# ==================================================================================
# ==================================================================================

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Atlassian Bitbucket Server"
NAME=atlbitbucket
#PIDFILE=$BITBUCKET_INSTALLDIR/work/catalina.pid
PIDFILE=$BITBUCKET_HOME/log/bitbucket.pid
SCRIPTNAME=/etc/init.d/$NAME
#Set Umask
umask 0027

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Define LSB log_* functions.
# To be replaced by LSB functions
# Defined here for distributions that don't define
# log_daemon_msg
log_daemon_msg () {
echo $@
}

# To be replaced by LSB functions
# Defined here for distributions that don't define
# log_end_msg
log_end_msg () {
retval=$1
if [ $retval -eq 0 ]; then
echo "."
else
echo " failed!"
fi
return $retval
}
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions


run_with_home() {
if [ "$RUNUSER" != "$USER" ]; then
su - "$RUNUSER" -c "export BITBUCKET_HOME=${BITBUCKET_HOME};${BITBUCKET_INSTALLDIR}/bin/$1"
else
export BITBUCKET_HOME=${BITBUCKET_HOME};${BITBUCKET_INSTALLDIR}/bin/$1
fi
}

#
# Function that starts the daemon/service
#
do_start()
{
run_with_home start-bitbucket.sh
}

#
# Function that stops the daemon/service
#
do_stop()
{
if [ -e $PIDFILE ]; then
run_with_home stop-bitbucket.sh
else
log_failure_msg "$NAME is not running."
fi
}


case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
if [ ! -e "$PIDFILE" ]; then
log_failure_msg "$NAME is not running."
return 1
fi
status_of_proc -p "$PIDFILE" "" $NAME && exit 0 || exit $?
;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events