Skip to content

Commit

Permalink
Kill the child process on SIG INT&TERM
Browse files Browse the repository at this point in the history
  • Loading branch information
jba-zen committed May 30, 2013
1 parent 74f2900 commit f8841ae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion deployment.py
Expand Up @@ -154,10 +154,16 @@ def isRunning():
return run

def quit(signum, frame):
global process
# we kill the serv when quitting.
if 'process' in globals():
os.killpg(process.pid, signal.SIGTERM)

# when we quit we set back the last deployed to 0
# this allow us to restart gracefully
updateLastDeployed(0)
print "\n\t -- Terminating --"

sys.exit(0)

def getBuildStatus():
Expand Down Expand Up @@ -218,6 +224,7 @@ def checkout(buildRevision):
os.chdir(previous)

def deploy():
global process
previous = os.getcwd()
os.chdir(jobname)
os.chdir(play_app_path)
Expand Down Expand Up @@ -245,7 +252,7 @@ def deploy():
cmd = 'target/start -DapplyEvolutions.default=' + play_app_apply_evolutions + ' -Dconfig.file=' + play_app_conf_file + ' -Dhttp.port='+play_app_port
if (play_app_logger):
cmd = cmd + ' -Dlogger.resource=' + play_app_logger_file
subprocess.Popen(cmd, shell=True)
process = subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid)
else:
# This should never happen as we retrieve only green builds
print '\t ~ Error: Compilation failed !'
Expand Down

0 comments on commit f8841ae

Please sign in to comment.