|
@@ -116,7 +116,7 @@ class Controller(cmd.Cmd):
|
|
|
'restart','start','stop','version','clear',
|
|
|
'fg','open','quit','remove','shutdown','status',
|
|
|
'tail','help']
|
|
|
- self.info=self.get_server_proxy().getAllProcessInfo()
|
|
|
+ self.info=self.get_supervisor().getAllProcessInfo()
|
|
|
cmd.Cmd.__init__(self, completekey, stdin, stdout)
|
|
|
for name, factory, kwargs in self.options.plugin_factories:
|
|
|
plugin = factory(self, **kwargs)
|
|
@@ -191,15 +191,20 @@ class Controller(cmd.Cmd):
|
|
|
def output(self, stuff):
|
|
|
if stuff is not None:
|
|
|
self.stdout.write(stuff + '\n')
|
|
|
+
|
|
|
+ def get_supervisor(self):
|
|
|
+ return self.get_server_proxy('supervisor')
|
|
|
|
|
|
- def get_server_proxy(self, namespace='supervisor'):
|
|
|
+ def get_server_proxy(self, namespace=None):
|
|
|
proxy = self.options.getServerProxy()
|
|
|
- proxy_for_namespace = getattr(proxy, namespace)
|
|
|
- return proxy_for_namespace
|
|
|
+ if namespace is None:
|
|
|
+ return proxy
|
|
|
+ else:
|
|
|
+ return getattr(proxy, namespace)
|
|
|
|
|
|
def upcheck(self):
|
|
|
try:
|
|
|
- supervisor = self.get_server_proxy()
|
|
|
+ supervisor = self.get_supervisor()
|
|
|
api = supervisor.getVersion() # deprecated
|
|
|
from supervisor import rpcinterface
|
|
|
if api != rpcinterface.API_VERSION:
|
|
@@ -451,7 +456,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
self.ctl.output('Error: bad argument %s' % modifier)
|
|
|
return
|
|
|
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
|
|
|
if bytes is None:
|
|
|
return self._tailf('/logtail/%s/%s' % (name, channel))
|
|
@@ -518,7 +523,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
else:
|
|
|
bytes = 1600
|
|
|
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
|
|
|
try:
|
|
|
output = supervisor.readLog(-bytes, 0)
|
|
@@ -565,7 +570,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
if not self.ctl.upcheck():
|
|
|
return
|
|
|
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
|
|
|
names = arg.strip().split()
|
|
|
|
|
@@ -592,7 +597,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
"processes.")
|
|
|
|
|
|
def do_pid(self, arg):
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
pid = supervisor.getPID()
|
|
|
self.ctl.output(str(pid))
|
|
|
|
|
@@ -621,7 +626,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
return
|
|
|
|
|
|
names = arg.strip().split()
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
|
|
|
if not names:
|
|
|
self.ctl.output("Error: start requires a process name")
|
|
@@ -681,7 +686,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
return
|
|
|
|
|
|
names = arg.strip().split()
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
|
|
|
if not names:
|
|
|
self.ctl.output('Error: stop requires a process name')
|
|
@@ -748,7 +753,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
else:
|
|
|
really = 1
|
|
|
if really:
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
try:
|
|
|
supervisor.shutdown()
|
|
|
except xmlrpclib.Fault, e:
|
|
@@ -768,7 +773,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
else:
|
|
|
really = 1
|
|
|
if really:
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
try:
|
|
|
supervisor.restart()
|
|
|
except xmlrpclib.Fault, e:
|
|
@@ -814,7 +819,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
return template % formatted
|
|
|
|
|
|
def do_avail(self, arg):
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
try:
|
|
|
configinfo = supervisor.getAllConfigInfo()
|
|
|
except xmlrpclib.Fault, e:
|
|
@@ -828,7 +833,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
self.ctl.output("avail\t\t\tDisplay all configured processes")
|
|
|
|
|
|
def do_reread(self, arg):
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
try:
|
|
|
result = supervisor.reloadConfig()
|
|
|
except xmlrpclib.Fault, e:
|
|
@@ -847,7 +852,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
def do_add(self, arg):
|
|
|
names = arg.strip().split()
|
|
|
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
for name in names:
|
|
|
try:
|
|
|
supervisor.addProcessGroup(name)
|
|
@@ -871,7 +876,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
def do_remove(self, arg):
|
|
|
names = arg.strip().split()
|
|
|
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
for name in names:
|
|
|
try:
|
|
|
result = supervisor.removeProcessGroup(name)
|
|
@@ -895,7 +900,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
def log(name, message):
|
|
|
self.ctl.output("%s: %s" % (name, message))
|
|
|
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
try:
|
|
|
result = supervisor.reloadConfig()
|
|
|
except xmlrpclib.Fault, e:
|
|
@@ -957,7 +962,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
self.help_clear()
|
|
|
return
|
|
|
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
|
|
|
if 'all' in names:
|
|
|
results = supervisor.clearAllProcessLogs()
|
|
@@ -1000,7 +1005,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
def do_version(self, arg):
|
|
|
if not self.ctl.upcheck():
|
|
|
return
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
self.ctl.output(supervisor.getSupervisorVersion())
|
|
|
|
|
|
def help_version(self):
|
|
@@ -1020,7 +1025,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
|
|
|
self.ctl.output('Error: too many process names supplied')
|
|
|
return
|
|
|
program = args[0]
|
|
|
- supervisor = self.ctl.get_server_proxy()
|
|
|
+ supervisor = self.ctl.get_supervisor()
|
|
|
try:
|
|
|
info = supervisor.getProcessInfo(program)
|
|
|
except xmlrpclib.Fault, msg:
|