mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-09 17:47:16 +00:00
21 lines
545 B
Python
21 lines
545 B
Python
|
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
|
||
|
|
||
|
def stop_process(self):
|
||
|
with suppress(SupervisorFault):
|
||
|
self.supervisor.stopProcess(self.process_name)
|
||
|
|
||
|
def start_process(self):
|
||
|
self.supervisor.startProcess(self.process_name)
|
||
|
|
||
|
def restart_process(self):
|
||
|
self.stop_process()
|
||
|
self.start_process()
|