|
@@ -119,7 +119,7 @@ class Controller(cmd.Cmd):
|
|
def help_EOF(self):
|
|
def help_EOF(self):
|
|
self._output("To quit, type ^D or use the quit command.")
|
|
self._output("To quit, type ^D or use the quit command.")
|
|
|
|
|
|
- def do_tailf(self, arg):
|
|
|
|
|
|
+ def _tailf(self, arg):
|
|
# cant really unit test this, sorry.
|
|
# cant really unit test this, sorry.
|
|
if not self._upcheck():
|
|
if not self._upcheck():
|
|
return
|
|
return
|
|
@@ -142,12 +142,9 @@ class Controller(cmd.Cmd):
|
|
handler.get(url)
|
|
handler.get(url)
|
|
asyncore.loop()
|
|
asyncore.loop()
|
|
except KeyboardInterrupt:
|
|
except KeyboardInterrupt:
|
|
|
|
+ self._output('')
|
|
return
|
|
return
|
|
|
|
|
|
- def help_tailf(self):
|
|
|
|
- self._output("tailf <processname>\tContinuous tail of named process "
|
|
|
|
- "stdout, Ctrl-C to exit.")
|
|
|
|
-
|
|
|
|
def do_tail(self, arg):
|
|
def do_tail(self, arg):
|
|
if not self._upcheck():
|
|
if not self._upcheck():
|
|
return
|
|
return
|
|
@@ -168,7 +165,7 @@ class Controller(cmd.Cmd):
|
|
if args[0].startswith('-'):
|
|
if args[0].startswith('-'):
|
|
what = args[0][1:]
|
|
what = args[0][1:]
|
|
if what == 'f':
|
|
if what == 'f':
|
|
- return self.do_tailf(args[1])
|
|
|
|
|
|
+ return self._tailf(args[1])
|
|
try:
|
|
try:
|
|
what = int(what)
|
|
what = int(what)
|
|
except:
|
|
except:
|
|
@@ -192,8 +189,7 @@ class Controller(cmd.Cmd):
|
|
if e.faultCode == rpc.Faults.FAILED:
|
|
if e.faultCode == rpc.Faults.FAILED:
|
|
self._output("Error: Log file doesn't yet exist on server")
|
|
self._output("Error: Log file doesn't yet exist on server")
|
|
else:
|
|
else:
|
|
- self.stdout.write(output)
|
|
|
|
- self.stdout.flush()
|
|
|
|
|
|
+ self._output(output)
|
|
|
|
|
|
def help_tail(self):
|
|
def help_tail(self):
|
|
self._output(
|
|
self._output(
|
|
@@ -227,7 +223,7 @@ class Controller(cmd.Cmd):
|
|
elif state == supervisord.ProcessStates.ERROR:
|
|
elif state == supervisord.ProcessStates.ERROR:
|
|
desc = info['spawnerr']
|
|
desc = info['spawnerr']
|
|
if not desc:
|
|
if not desc:
|
|
- desc = 'unknown error (try "tailf %s")' % info['name']
|
|
|
|
|
|
+ desc = 'unknown error (try "tail %s")' % info['name']
|
|
|
|
|
|
elif state in (supervisord.ProcessStates.STOPPED,
|
|
elif state in (supervisord.ProcessStates.STOPPED,
|
|
supervisord.ProcessStates.KILLED,
|
|
supervisord.ProcessStates.KILLED,
|
|
@@ -256,7 +252,14 @@ class Controller(cmd.Cmd):
|
|
|
|
|
|
if processnames:
|
|
if processnames:
|
|
for processname in processnames:
|
|
for processname in processnames:
|
|
- info = supervisor.getProcessInfo(processname)
|
|
|
|
|
|
+ try:
|
|
|
|
+ info = supervisor.getProcessInfo(processname)
|
|
|
|
+ except xmlrpclib.Fault, e:
|
|
|
|
+ if e.faultCode == rpc.Faults.BAD_NAME:
|
|
|
|
+ self._output('No such process %s' % processname)
|
|
|
|
+ else:
|
|
|
|
+ raise
|
|
|
|
+ continue
|
|
newinfo = self._interpretProcessInfo(info)
|
|
newinfo = self._interpretProcessInfo(info)
|
|
self._output(template % newinfo)
|
|
self._output(template % newinfo)
|
|
else:
|
|
else:
|
|
@@ -420,6 +423,46 @@ class Controller(cmd.Cmd):
|
|
"started in")
|
|
"started in")
|
|
self._output(" priority order (see config file)")
|
|
self._output(" priority order (see config file)")
|
|
|
|
|
|
|
|
+ def do_shutdown(self, arg):
|
|
|
|
+ if self.options.interactive:
|
|
|
|
+ yesno = raw_input('Really shut the supervisord process down y/N? ')
|
|
|
|
+ really = yesno.lower().startswith('y')
|
|
|
|
+ else:
|
|
|
|
+ really = 1
|
|
|
|
+ if really:
|
|
|
|
+ supervisor = self._get_supervisor()
|
|
|
|
+ try:
|
|
|
|
+ supervisor.shutdown()
|
|
|
|
+ except xmlrpclib.Fault, e:
|
|
|
|
+ if e.faultCode == rpc.Faults.SHUTDOWN_STATE:
|
|
|
|
+ self._output('ERROR: already shutting down')
|
|
|
|
+ else:
|
|
|
|
+ self._output('Shutting down')
|
|
|
|
+
|
|
|
|
+ def help_shutdown(self):
|
|
|
|
+ self._output("shutdown \t\tShut the remote supervisord down.")
|
|
|
|
+
|
|
|
|
+ def do_reload(self, arg):
|
|
|
|
+ if self.options.interactive:
|
|
|
|
+ yesno = raw_input('Really restart the remote supervisord process '
|
|
|
|
+ 'y/N? ')
|
|
|
|
+ really = yesno.lower().startswith('y')
|
|
|
|
+ else:
|
|
|
|
+ really = 1
|
|
|
|
+ if really:
|
|
|
|
+ supervisor = self._get_supervisor()
|
|
|
|
+ try:
|
|
|
|
+ supervisor.restart()
|
|
|
|
+ except xmlrpclib.Fault, e:
|
|
|
|
+ if e.faultCode == rpc.Faults.SHUTDOWN_STATE:
|
|
|
|
+ self._output('ERROR: already shutting down')
|
|
|
|
+ else:
|
|
|
|
+ self._output('Restarting supervisord')
|
|
|
|
+
|
|
|
|
+ def help_reload(self):
|
|
|
|
+ self._output("reload \t\tRestart the remote supervisord.")
|
|
|
|
+
|
|
|
|
+
|
|
def main(args=None, options=None):
|
|
def main(args=None, options=None):
|
|
if options is None:
|
|
if options is None:
|
|
options = ClientOptions()
|
|
options = ClientOptions()
|