2016-02-01 17:49:17 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
|
|
|
|
2016-02-08 19:03:38 +02:00
|
|
|
from base.config.ConfigManager import ConfigManager
|
2016-02-25 17:24:07 +02:00
|
|
|
from base.deamon.BaseDeamon import BaseDaemon
|
|
|
|
from base.logger.AhenkLogger import Logger
|
2016-02-21 03:56:08 +02:00
|
|
|
from base.Scope import Scope
|
2016-02-25 11:35:16 +02:00
|
|
|
#from base.messaging.Messaging import Messaging
|
2016-02-08 19:03:38 +02:00
|
|
|
import sys,logging
|
2016-02-01 17:49:17 +02:00
|
|
|
|
2016-02-08 19:03:38 +02:00
|
|
|
|
2016-02-25 17:24:07 +02:00
|
|
|
class AhenkDeamon(BaseDaemon):
|
2016-02-08 19:03:38 +02:00
|
|
|
"""docstring for AhenkDeamon"""
|
2016-02-21 03:56:08 +02:00
|
|
|
|
|
|
|
def run(self):
|
2016-02-25 17:24:07 +02:00
|
|
|
print "merhaba dunya"
|
2016-02-25 01:46:27 +02:00
|
|
|
globalscope = Scope()
|
|
|
|
globalscope.setInstance(globalscope)
|
|
|
|
|
2016-02-21 03:56:08 +02:00
|
|
|
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)
|
2016-02-08 19:03:38 +02:00
|
|
|
|
2016-02-21 03:56:08 +02:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
pidfilePath='/var/run/ahenk.pid'
|
|
|
|
|
2016-02-25 17:24:07 +02:00
|
|
|
ahenkdaemon = AhenkDeamon(pidfilePath)
|
2016-02-21 03:56:08 +02:00
|
|
|
|
2016-02-25 01:46:27 +02:00
|
|
|
print sys.argv
|
2016-02-08 19:03:38 +02:00
|
|
|
if len(sys.argv) == 2:
|
|
|
|
if sys.argv[1] == "start":
|
2016-02-25 01:46:27 +02:00
|
|
|
print "starting"
|
2016-02-25 17:24:07 +02:00
|
|
|
ahenkdaemon.start()
|
|
|
|
print ahenkdaemon.get_pid()
|
2016-02-08 19:03:38 +02:00
|
|
|
elif sys.argv[1] == 'stop':
|
2016-02-25 17:24:07 +02:00
|
|
|
ahenkdaemon.stop()
|
2016-02-08 19:03:38 +02:00
|
|
|
elif sys.argv[1] == 'restart':
|
2016-02-25 17:24:07 +02:00
|
|
|
ahenkdaemon.restart()
|
2016-02-08 19:03:38 +02:00
|
|
|
elif sys.argv[1] == 'status':
|
|
|
|
# print status
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
print 'Unknown command. Usage : %s start|stop|restart|status' % sys.argv[0]
|
|
|
|
sys.exit(2)
|
|
|
|
sys.exit(0)
|
|
|
|
else:
|
|
|
|
print 'Usage : %s start|stop|restart|status' % sys.argv[0]
|
|
|
|
sys.exit(2)
|