mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2025-06-28 18:05:12 +00:00
Extract process managing logic to SupervisorMixin from event handlers
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import xmlrpc.client, zmq
|
||||
from contextlib import suppress
|
||||
from xmlrpc.client import Fault as SupervisorFault
|
||||
|
||||
from .config.envvars import SUPERVISOR_HTTP_URI
|
||||
|
||||
@ -14,6 +16,17 @@ def create_source_code_response_data(filename, content, language):
|
||||
class SupervisorMixin:
|
||||
supervisor = xmlrpc.client.ServerProxy(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()
|
||||
|
||||
|
||||
class ZMQConnectorBase:
|
||||
def __init__(self, zmq_context=None):
|
||||
|
Reference in New Issue
Block a user