7

I have install PostgreSQL, Atlassian JIRA, Stash, Confluence and Crowd on a single Ubuntu 12.04 Server. They are integrated and working per Atlassian documentation.

One thing I did notice is that the product suite doesn't tolerate dependent components being down. For example, if Crowd is stopped, users can no longer login. If PostgreSQL is being stopped for maintenance reasons, the dependent applications may never recover.

Every night the system goes through a maintenance window, during which the operating system and software may be patched. The external DNS is configured to gracefully show a maintenance page if there is an error with the applications.

Every now and then, PostgreSQL may be stopped, patched and then started. How do I configure my Upstart scripts to take dependencies into account? I configured the "start on", but it has no effect.

I'm comfortable writing Windows services and configuring their dependencies during install (e.g. windows installer, or PowerShell).

Testcases:

  • I stopped all services. I then started Confluence, expecting that it would either fail (since PostgreSQL and Crowd is stopped), or would automatically attempt to start PostgreSQL and Crowd. Neither happened.

  • I started all services. I then stopped Crowd, expecting that Confluence, JIRA and Stash will be stopped. It only stopped Crowd and all the other services kept running, but failed to function correctly.

Dependencies:

  • Crowd: PostgreSQL, Networking
  • Confluence: PostgreSQL, Networking, Crowd
  • JIRA: PostgreSQL, Networking, Crowd
  • Stash: PostgreSQL, Networking, Crowd

Confluence

# confluence

description "Atlassian Confluence"

start on (net-device-up and local-filesystems and postgresql and runlevel [2345] and crowd)
stop on runlevel [!2345]

respawn

kill timeout 30

env RUN_AS_USER=confluence
env BASEDIR=/usr/local/bin/confluence

script
    LOGFILE=/var/log/confluence/confluence.`date +%Y-%m-%d`.log
    exec su - $RUN_AS_USER -c "$BASEDIR/bin/catalina.sh run" >> $LOGFILE 2>&1
end script

JIRA

description "Atlassian JIRA"

start on (net-device-up and local-filesystems and postgresql and runlevel [2345] and crowd)
stop on runlevel [!2345]

respawn

kill timeout 30

env RUN_AS_USER=jira
env BASEDIR=/usr/local/bin/jira

script
    LOGFILE=/var/log/jira/jira.`date +%Y-%m-%d`.log
    exec su - $RUN_AS_USER -c "$BASEDIR/bin/catalina.sh run" >> $LOGFILE 2>&1
end script

Stash

description "Atlassian Stash"

start on (net-device-up and local-filesystems and postgresql and runlevel [2345] and crowd)
stop on runlevel [!2345]

respawn

kill timeout 30

env RUN_AS_USER=stash
env BASEDIR=/usr/local/bin/stash
env STASH_HOME="/var/local/lib/stash"

script
    LOGFILE=/var/log/stash/stash.`date +%Y-%m-%d`.log
    exec su - $RUN_AS_USER -c "$BASEDIR/bin/start-stash.sh -fg" >> $LOGFILE 2>&1
end script

Crowd

# crowd

description "Atlassian Crowd - Single Sign-On (SSO) and Identity Management"

start on (net-device-up and local-filesystems and postgresql and runlevel [2345])
stop on runlevel [!2345]

respawn

kill timeout 30

env RUN_AS_USER=crowd
env BASEDIR=/usr/local/bin/crowd/apache-tomcat

script
    LOGFILE=/var/log/crowd/crowd.`date +%Y-%m-%d`.log
    exec su - $RUN_AS_USER -c "$BASEDIR/bin/catalina.sh run" >> $LOGFILE 2>&1
end script

PostgreSQL was installed via APT and starts up automatically during startup.

  • Did you find out a way to start crowd after postgresql is started ? – Mevin Babu Oct 11 '14 at 20:30
9
+50

Try:

  • Crowd

    start on (net-device-up and started postgresql)
    stop on stopping postgresql
    
  • Confluence

    start on started crowd
    stop on stopping crowd
    
  • Stash

    start on started crowd
    stop on stopping crowd
    
  • JIRA

    start on started crowd
    stop on stopping crowd
    

Reference: http://upstart.ubuntu.com/cookbook/

  • 6.32.2 Start depends on another service
  • 6.33.2 Stop before depended-upon service
  • After running for a while, I noticed that services do not start automatically upon startup after postgresql started. In essence, after automatic updates all services are dead. – bloudraak May 7 '14 at 23:10
  • Could you check sudo service postgresql status and sudo service crowd status – user.dz May 7 '14 at 23:16
  • postgresql is "Running clusters: 9.1/main" and crowd is "crowd stop/waiting". – bloudraak May 7 '14 at 23:20
  • try modifying start on (net-device-up and started postgresql) to start on started postgresql – user.dz May 7 '14 at 23:23
  • "start on started postgresql" produce the same results. PostgreSQL starts after reboot, but not Crowd. – bloudraak May 7 '14 at 23:25
6

This is going to be a little hard, because postgresql is not a native upstart job. You need to do the following:

  1. Add the line initctl emit -n started JOB=postgresql at the END of the start portion of /etc/init.d/postgresql
  2. Add the line initctl emit stopping JOB=postgresql to the BEGINNING of the stop portion of /etc/init.d/postgresql
  3. Change crowd to:

    start on started postgresql
    stop on stopping postgresql
    

That should be it. If you need help for steps 1 and 2, just ask.

  • Thanks, that solves the issue for me (not sure why @bloudraak accepted the other answer), Since the postgresql script has a common section for start/stop/restart/reload 1. and 2. should be put in if [ "$1" = start -o "$1" = restart ]; then ...; fi and if [ "$1" = stop -o "$1" = restart ]; then ...; fi blocks respectively. Strictly speaking the former should also check the EXIT variable. – user686249 Oct 28 '15 at 22:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.