6

I asked this question at Atlassian but figured serverfault might be more appropriate as it's more of a sysadmin question than an Atlassian question:

I have been attempting to follow this guide to have FishEye+Crucible start at boot. JIRA is already installed and running as it's own user (jira) on Ubuntu at boot, but I cannot get Fisheye+Crucible (aka fecru) to do the same.

I followed the instructions there (and Ubuntu related note in the comments of the page) and rebooted, JIRA started on it's own as usual but fecru did not. Does it have something to do with the RUN_AS variable, which I set to 'jira'? Will that command run at boot without prompting for a password for the user 'jira'? I figured it would not prompt because the program JIRA starts at boot fine as that user...

Using:

Ubuntu 10.04 Lucid

Jira 5.0

Crucible+Fisheye 2.7.11

Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
xref
  • 273
  • 2
  • 14

3 Answers3

1

As this question popped up again and the answers are now outdated since the switch to systemd by the major distributions I'll add my systemd service definition for JIRA:

/etc/systemd/system/jira.service

[Unit]
Description=Atlassian JIRA
After=syslog.target network.target

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/jira
ExecStart=/path/to/jira/bin/startup.sh
ExecStop=/path/to/jira/bin/shutdown.sh
PIDFile=/path/to/jira/work/catalina.pid
SuccessExitStatus=143
User=jira
Group=jira
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

/etc/sysconfig/jira

# Name of the user to run as
USER=jira
# Location of application's bin directory
CATALINA_HOME=/path/to/jira
# Location of Java JDK
export JAVA_HOME=/usr/lib/jvm/java-8-oracle

Replace /path/to/jira with your application directory.

For the other Atlassian tools it's basically the same, just the startup scripts and the PID file location differ slightly:

  • Confluence

    • $appdir/bin/startup.sh
    • $appdir/bin/shutdown.sh
    • $appdir/work/catalina.pid
  • FishEye

    • $appdir/bin/start.sh
    • $appdir/bin/stop.sh
  • Bamboo

    • $appdir/bin/start-bamboo.sh
    • $appdir/bin/stop-bamboo.sh
  • Crowd

    • $appdir/bin/startup.sh
    • $appdir/bin/shutdown.sh
    • $appdir/apache-tomcat/work/catalina.pid

FishEye doesn't have support for a PID file yet, so currently it is necessary to use the workaround from that issue and add this line to fisheyectl.sh after the nohop command:

echo $! > $FISHEYE_INST/var/fisheye.pid

For Bamboo the PID file has to be explicitly defined via the CATALINA_PID variable (see $appdir/bin/catalina.sh). I haven't tested it yet, but it should be possible to set this variable in the EnvironmentFile file.

After the service definitions are created:

# start JIRA
sudo systemctl start jira
# enable automatic start on boot
sudo systemctl enable jira
Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
0

Relevant bits of init script I use:

case "$1" in
    start)
        sudo -u fisheye /path/to/fisheye/startf.sh

    stop)
        sudo -u fisheye /path/to/fisheye/stopf.sh
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

Contents of startf.sh:

source /home/fisheye/.profile
$FISHEYE_HOME/bin/start.sh

stopf.sh:

source /home/fisheye/.profile
$FISHEYE_HOME/bin/stop.sh

Relevant contents of .profile:

export JAVA_HOME=/path/to/java/
export FISHEYE_OPTS="-Xms512m -Xmx4800m -XX:MaxPermSize=512m"
export FISHEYE_HOME=/home/fisheye/fecru-x.x.x
export FISHEYE_INST=/home/fisheye/inst-example

Of course I could have added the source .profile statement in the fisheye provided start and stop scripts, but that would mean having to edit it again after an upgrade. I tried to keep the fisheye files unchanged as much as possible.

aseq
  • 4,550
  • 1
  • 22
  • 46
0

I realize this is an old thread, but I was unable to find an answer, so here it is:

edit fisheyectl.sh and change nohup sh -c "exec $CMD" >> $FISHEYE_INST/var/log/fisheye.out 2>&1 & to not use nohup (because upstart wants it to run in foreground:

#echo "Starting FishEye/Crucible... Output redirected to $FISHEYE_INST/var/log/fisheye.out"
#nohup sh -c "exec $CMD" >> $FISHEYE_INST/var/log/fisheye.out 2>&1 &
sh -c "exec $CMD"

The create your /etc/init/fisheye.conf file (I named mine crucible, but doesn't matter):

# Crucible Upstart
#
# Required-Start:
# Required-Stop:

description "Crucible Server"

start on runlevel [2345]
stop on runlevel [!2345]

setuid crucible
setgid crucible
env FISHEYE_HOME="/home/crucible/crucible"
env FISHEYE_INST="/home/crucible/crucible-datastore"

# Give up if restart occurs 10 times in 30 seconds.
respawn limit 10 30

# keep it running in foreground to let upstart manage it
exec ~crucible/crucible/bin/start.sh
respawn

Note, you may need to alter the setuid and setgid depending on the user you run it as. You may also need to alter the env lines for your paths.

Clayton Dukes
  • 444
  • 2
  • 9