Skip to content
Snippets Groups Projects
daqWebService.py 1.7 KiB
Newer Older
#!/usr/bin/env python

#
# DM DAQ Web Service
#

from dm.common.service.dmRestWebServiceBase import DmRestWebServiceBase
from dm.common.utility.dmModuleManager import DmModuleManager
from dm.common.utility.configurationManager import ConfigurationManager
from dm.common.processing.fileProcessingManager import FileProcessingManager
from dm.daq_web_service.service.impl.daqProcessingCompleteNotificationPlugin import DaqProcessingCompleteNotificationPlugin

from dm.daq_web_service.service.impl.fileSystemObserver import FileSystemObserver 
from daqWebServiceRouteMapper import DaqWebServiceRouteMapper

class DaqWebService(DmRestWebServiceBase):
 
    def __init__(self):
        DmRestWebServiceBase.__init__(self, DaqWebServiceRouteMapper)

    def initDmModules(self):
        self.logger.debug('Initializing dm modules')

        # Add modules that will be started.
        moduleManager = DmModuleManager.getInstance()
        moduleManager.addModule(FileSystemObserver.getInstance())
        moduleManager.addModule(FileProcessingManager.getInstance())

        # Requred processing plugin
        notificationPlugin = DaqProcessingCompleteNotificationPlugin()
        FileProcessingManager.getInstance().appendFileProcessor(notificationPlugin)
        self.logger.debug('Initialized dm modules')

    def getDefaultServerHost(self):
        return ConfigurationManager.getInstance().getServiceHost()

    def getDefaultServerPort(self):
        return ConfigurationManager.getInstance().getServicePort()

####################################################################
# Run service

if __name__ == '__main__':
    ConfigurationManager.getInstance().setServiceName('daq-web-service')
    service = DaqWebService();
    service.run()