mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-28 13:52:21 +03:00
added scope instance method
This commit is contained in:
parent
35bb13b833
commit
f3e637b673
3 changed files with 23 additions and 22 deletions
|
@ -11,19 +11,11 @@ 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
|
||||
globalscope = Scope()
|
||||
globalscope.setInstance(globalscope)
|
||||
|
||||
configFilePath='/etc/ahenk/ahenk.conf'
|
||||
configfileFolderPath='/etc/ahenk/config.d/'
|
||||
|
||||
|
@ -36,25 +28,22 @@ class AhenkDeamon(BaseDeamon):
|
|||
logger.info("obaraaa")
|
||||
globalscope.setLogger(logger)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
pidfilePath='/var/run/ahenk.pid'
|
||||
|
||||
deamon = AhenkDeamon(pidfilePath)
|
||||
ahenkdeamon = AhenkDeamon(pidfilePath)
|
||||
|
||||
print sys.argv
|
||||
if len(sys.argv) == 2:
|
||||
if sys.argv[1] == "start":
|
||||
deamon.start()
|
||||
print "starting"
|
||||
ahenkdeamon.start()
|
||||
elif sys.argv[1] == 'stop':
|
||||
deamon.stop()
|
||||
ahenkdeamon.stop()
|
||||
elif sys.argv[1] == 'restart':
|
||||
deamon.restart()
|
||||
ahenkdeamon.restart()
|
||||
elif sys.argv[1] == 'status':
|
||||
# print status
|
||||
pass
|
||||
|
|
|
@ -5,12 +5,24 @@
|
|||
|
||||
class Scope(object):
|
||||
"""docstring for Scope"""
|
||||
|
||||
scopeInstance=None
|
||||
|
||||
def __init__(self):
|
||||
super(Scope, self).__init__()
|
||||
self.customMap = {}
|
||||
self.configurationManager=None
|
||||
self.logger=None
|
||||
|
||||
@staticmethod
|
||||
def getInstance():
|
||||
return scopeInstance
|
||||
|
||||
@staticmethod
|
||||
def setInstance(scopeObj):
|
||||
global scopeInstance
|
||||
scopeInstance = scopeObj
|
||||
|
||||
def getCustomMap(self):
|
||||
return self.customMap
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
import logging
|
||||
import logging.config
|
||||
from ahenkd import AhenkDeamon
|
||||
from base.Scope import Scope
|
||||
|
||||
class Logger(object):
|
||||
"""docstring for Logger"""
|
||||
def __init__(self):
|
||||
super(Logger, self).__init__()
|
||||
scope = AhenkDeamon.scope()
|
||||
scope = Scope.getInstance()
|
||||
configManager = scope.getConfigurationManager()
|
||||
|
||||
logging.config.fileConfig(configManager.get('BASE','logConfigurationFilePath'))
|
||||
|
|
Loading…
Reference in a new issue