Skip to content

Commit

Permalink
Decomposed application name and script paths into variables so modify…
Browse files Browse the repository at this point in the history
…ing for use with confluence is easier.
  • Loading branch information
sean-m committed Feb 4, 2013
1 parent 615a474 commit deac628
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions jira-init.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,36 +20,39 @@


import sys, os, subprocess, re, time import sys, os, subprocess, re, time


APP_NAME = 'JIRA'
APP_DIR='/data/jira_main/jira-std/' APP_DIR='/data/jira_main/jira-std/'
APP_START = 'bin/start-jira.sh'
APP_STOP = 'bin/stop-jira.sh'


def lock(): def lock():
""" """
Create the /var/lock/subsys file Create the /var/lock/subsys file
""" """
open('/var/lock/subsys/jira', 'w').close() open('/var/lock/subsys/' + APP_NAME, 'w').close()


def locked(): def locked():
""" """
Return True if the lock file exists Return True if the lock file exists
""" """
return os.path.exists('/var/lock/subsys/jira') return os.path.exists('/var/lock/subsys/' + APP_NAME)


def unlock(): def unlock():
""" """
Remove the /var/lock/subsys file Remove the /var/lock/subsys file
""" """
os.remove('/var/lock/subsys/jira') os.remove('/var/lock/subsys/' + APP_NAME)


def start(): def start():
count = 0 count = 0


if not locked(): if not locked():
print('Starting JIRA...') print('Starting ' + APP_NAME + '...')


try: try:
subprocess.check_call(APP_DIR + 'bin/start-jira.sh', shell=False) subprocess.check_call(APP_DIR + APP_START , shell=False)
except: except:
print('There was an error starting JIRA') print('There was an error starting ' + APP_NAME)
return subprocess.returncode return subprocess.returncode


lock() lock()
Expand All @@ -61,14 +64,24 @@ def stop():
""" """
Shut everything down, clean up. Shut everything down, clean up.
""" """
print('Stopping JIRA...')
if locked():
print('Stopping ' + APP_NAME + '...')
try:
subprocess.check_call(APP_DIR + APP_STOP, shell=False)
unlock()
except:
print('There was an error stopping ' + APP_NAME)
return subprocess.returncode
else:
print('No process lock, check status')



def restart(): def restart():
""" """
Stop and then start Stop and then start
""" """
stop() stop()
lock()
start() start()


def status(): def status():
Expand Down

0 comments on commit deac628

Please sign in to comment.