mirror of
				https://github.com/avatao-content/baseimage-tutorial-framework
				synced 2025-11-04 12:22:54 +00:00 
			
		
		
		
	Implement ProcessManagingEventHandler
This commit is contained in:
		
							
								
								
									
										15
									
								
								lib/tfw/components/process_managing_event_handler.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								lib/tfw/components/process_managing_event_handler.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
from tfw.event_handler_base import EventHandlerBase
 | 
			
		||||
from tfw.components.mixins import SupervisorMixin
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ProcessManagingEventHandler(EventHandlerBase, SupervisorMixin):
 | 
			
		||||
    def __init__(self, anchor, supervisor_process_name):
 | 
			
		||||
        super().__init__(anchor)
 | 
			
		||||
        self.process = supervisor_process_name
 | 
			
		||||
        self.commands = {'start':   self.start_process,
 | 
			
		||||
                         'stop':    self.stop_process,
 | 
			
		||||
                         'restart': self.restart_process}
 | 
			
		||||
 | 
			
		||||
    def handle_event(self, anchor, data_json):
 | 
			
		||||
        data = data_json['data']
 | 
			
		||||
        self.commands[data['command']]()
 | 
			
		||||
		Reference in New Issue
	
	Block a user