From f0e023cc82ca628c0ea175a270793420fcd59a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20Ba=C5=9Faran?= Date: Sun, 21 Feb 2016 03:56:08 +0200 Subject: [PATCH] updated ahenk deamon --- opt/ahenk/ahenkd.py | 40 +++++++++++++++++++++++++++++----------- opt/ahenk/base/Scope.py | 2 +- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/opt/ahenk/ahenkd.py b/opt/ahenk/ahenkd.py index d3ace1d..0d3c6c1 100644 --- a/opt/ahenk/ahenkd.py +++ b/opt/ahenk/ahenkd.py @@ -5,30 +5,49 @@ from base.config.ConfigManager import ConfigManager from base.deamon.BaseDeamon import BaseDeamon from base.logging.AhenkLogger import Logger +from base.Scope import Scope import sys,logging class AhenkDeamon(BaseDeamon): """docstring for AhenkDeamon""" + globalscope=None def __init__(self, arg): super(AhenkDeamon, self).__init__() self.arg = arg + global globalscope + globalscope=Scope() + + @staticmethod + def scope(): + return globalscope + + def run(self): + global globalscope + configFilePath='/etc/ahenk/ahenk.conf' + configfileFolderPath='/etc/ahenk/config.d/' + + #configuration manager must be first load + configManager = ConfigManager(configFilePath,configfileFolderPath) + config = configManager.read() + globalscope.setConfigurationManager(config) + + logger = Logger() + logger.info("obaraaa") + globalscope.setLogger(logger) + + + + + + if __name__ == '__main__': - configFilePath='/etc/ahenk/ahenk.conf' - configfileFolderPath='/etc/ahenk/config.d/' pidfilePath='/var/run/ahenk.pid' - configManager = ConfigManager(configFilePath,configfileFolderPath) - config = configManager.read() - - logger = Logger('/tmp/ahenk.log',logging.DEBUG) - logger.info("obaraaa") - -""" deamon = AhenkDeamon(pidfilePath) - + if len(sys.argv) == 2: if sys.argv[1] == "start": deamon.start() @@ -46,4 +65,3 @@ if __name__ == '__main__': else: print 'Usage : %s start|stop|restart|status' % sys.argv[0] sys.exit(2) -""" \ No newline at end of file diff --git a/opt/ahenk/base/Scope.py b/opt/ahenk/base/Scope.py index 62335a6..1c64a04 100644 --- a/opt/ahenk/base/Scope.py +++ b/opt/ahenk/base/Scope.py @@ -23,7 +23,7 @@ class Scope(object): def getConfigurationManager(self): return self.configurationManager - def serConfigurationManager(self,configurationManager): + def setConfigurationManager(self,configurationManager): self.configurationManager = configurationManager def getLogger(self):