Browse Source

Handle all start faults on the web interface. Fixes #219

Mike Naberezny 10 years ago
parent
commit
ff952b1730
2 changed files with 36 additions and 8 deletions
  1. 7 2
      CHANGES.txt
  2. 29 6
      supervisor/web.py

+ 7 - 2
CHANGES.txt

@@ -36,8 +36,13 @@
 - Added ``signal`` command to supervisorctl.  Thanks to Moriyoshi Koizumi and
   Marc Abramowitz for the patches.
 
-- Fixed a bug where ``tail group:*`` would cause a 500 Internal Server Error
-  rather than returning a BAD_NAME fault.
+- Fixed a bug where ``tail group:*`` in ``supervisorctl`` would show a 500
+  Internal Server Error rather than a BAD_NAME fault.
+
+- Fixed a bug where the web interface would show a 500 Internal Server Error
+  instead of an error message for some process start faults.
+
+- Removed medusa files not used by Supervisor.
 
 3.1.1 (2014-08-11)
 ------------------

+ 29 - 6
supervisor/web.py

@@ -367,13 +367,36 @@ class StatusView(MeldView):
                         callback = rpcinterface.supervisor.startProcess(
                             namespec)
                     except RPCError as e:
-                        if e.code == Faults.SPAWN_ERROR:
-                            def spawnerr():
-                                return 'Process %s spawn error' % namespec
-                            spawnerr.delay = 0.05
-                            return spawnerr
+                        if e.code == Faults.NO_FILE:
+                            msg = 'no such file'
+                        elif e.code == Faults.NOT_EXECUTABLE:
+                            msg = 'file not executable'
+                        elif e.code == Faults.ALREADY_STARTED:
+                            msg = 'already started'
+                        elif e.code == Faults.SPAWN_ERROR:
+                            msg = 'spawn error'
+                        elif e.code == Faults.ABNORMAL_TERMINATION:
+                            msg = 'abnormal termination'
+                        else:
+                            msg = 'unexpected rpc fault code %d' % e.code
+                        def starterr():
+                            return 'ERROR: Process %s: %s' % (namespec, msg)
+                        starterr.delay = 0.05
+                        return starterr
+
                     def startprocess():
-                        if callback() is NOT_DONE_YET:
+                        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 code %d' % e.code
+                            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