Skip to content

Commit

Permalink
Fix start/stop buttons on web broken by faster start/stop patch
Browse files Browse the repository at this point in the history
In past versions, startProcess() and stopProcess() would always return
a callback.  50d1857 changed this
so they may return either a callback or a bool, but the web interface
was not updated.
  • Loading branch information
mnaberez committed Nov 15, 2015
1 parent 4306528 commit 11ffa51
Showing 1 changed file with 47 additions and 33 deletions.
80 changes: 47 additions & 33 deletions supervisor/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,9 @@ def wrong():

if action == 'start':
try:
callback = rpcinterface.supervisor.startProcess(
namespec)
bool_or_callback = (
rpcinterface.supervisor.startProcess(namespec)
)
except RPCError as e:
if e.code == Faults.NO_FILE:
msg = 'no such file'
Expand All @@ -357,47 +358,60 @@ def starterr():
starterr.delay = 0.05
return starterr

def startprocess():
try:
result = callback()
except RPCError as e:
if e.code == Faults.SPAWN_ERROR:
msg = 'spawn error'
elif e.code == Faults.ABNORMAL_TERMINATION:
msg = 'abnormal termination'
else:
msg = 'unexpected rpc fault [%d] %s' % (
e.code, e.text)
return 'ERROR: Process %s: %s' % (namespec, msg)

if result is NOT_DONE_YET:
return NOT_DONE_YET
return 'Process %s started' % namespec
startprocess.delay = 0.05
return startprocess
if callable(bool_or_callback):
def startprocess():
try:
result = bool_or_callback()
except RPCError as e:
if e.code == Faults.SPAWN_ERROR:
msg = 'spawn error'
elif e.code == Faults.ABNORMAL_TERMINATION:
msg = 'abnormal termination'
else:
msg = 'unexpected rpc fault [%d] %s' % (
e.code, e.text)
return 'ERROR: Process %s: %s' % (namespec, msg)

if result is NOT_DONE_YET:
return NOT_DONE_YET
return 'Process %s started' % namespec
startprocess.delay = 0.05
return startprocess
else:
def startdone():
return 'Process %s started' % namespec
startdone.delay = 0.05
return startdone

elif action == 'stop':
try:
callback = rpcinterface.supervisor.stopProcess(
namespec)
bool_or_callback = (
rpcinterface.supervisor.stopProcess(namespec)
)
except RPCError as e:
def stoperr():
return 'unexpected rpc fault [%d] %s' % (
e.code, e.text)
stoperr.delay = 0.05
return stoperr

def stopprocess():
try:
result = callback()
except RPCError as e:
return 'unexpected rpc fault [%d] %s' % (
e.code, e.text)
if result is NOT_DONE_YET:
return NOT_DONE_YET
return 'Process %s stopped' % namespec
stopprocess.delay = 0.05
return stopprocess
if callable(bool_or_callback):
def stopprocess():
try:
result = bool_or_callback()
except RPCError as e:
return 'unexpected rpc fault [%d] %s' % (
e.code, e.text)
if result is NOT_DONE_YET:
return NOT_DONE_YET
return 'Process %s stopped' % namespec
stopprocess.delay = 0.05
return stopprocess
else:
def stopdone():
return 'Process %s stopped' % namespec
stopdone.delay = 0.05
return stopdone

elif action == 'restart':
callback = rpcinterface.system.multicall(
Expand Down

0 comments on commit 11ffa51

Please sign in to comment.