2018-02-13 16:51:19 +00:00
|
|
|
import xmlrpc.client
|
|
|
|
from contextlib import suppress
|
|
|
|
from xmlrpc.client import Fault as SupervisorFault
|
|
|
|
|
|
|
|
from tfw.config import tfwenv
|
|
|
|
|
|
|
|
|
|
|
|
class SupervisorMixin:
|
|
|
|
supervisor = xmlrpc.client.ServerProxy(tfwenv.SUPERVISOR_HTTP_URI).supervisor
|
|
|
|
|
2018-02-27 14:54:10 +00:00
|
|
|
def stop_process(self, process_name):
|
2018-02-13 16:51:19 +00:00
|
|
|
with suppress(SupervisorFault):
|
2018-02-27 14:54:10 +00:00
|
|
|
self.supervisor.stopProcess(process_name)
|
2018-02-13 16:51:19 +00:00
|
|
|
|
2018-02-27 14:54:10 +00:00
|
|
|
def start_process(self, process_name):
|
|
|
|
self.supervisor.startProcess(process_name)
|
2018-02-13 16:51:19 +00:00
|
|
|
|
2018-02-27 14:54:10 +00:00
|
|
|
def restart_process(self, process_name):
|
|
|
|
self.stop_process(process_name)
|
|
|
|
self.start_process(process_name)
|