示例#1
0
文件: sqdHelper.py 项目: ajZiiiN/sqd
    def __init__(self):
        self.configFile = "configL.json"
        self.configDir = "/etc/sqd"
        self.baseConfigFile = "config.json"

        self.config = dict()
        self.leaderConfig = dict()
        self.workers = dict() # mapping between ip and msgObject || each message object has inbox
        self.clients = dict() # mapping between ip and msgObject || each message object has inbox

        self.job_functions = {
            "worker": {
                "add": self.addWorker,
                "remove" : self.removeWorker
            },
            "client": {
                "add": self.addClient,
                "remove" : self.removeClient

            }
        }

        # checking config directory
        if utils.checkCreateDir(self.configDir):
            if not os.path.exists(os.path.join(self.configDir, self.configFile )) \
                and not os.path.exists(os.path.join(self.configDir, self.baseConfigFile )) :
                self.createFromSample("all")
                print "Config created from sample..."
            else:
                print "Configs are messed up, please check and clean. "

        if os.path.exists (os.path.join (self.configDir, self.configFile )):
            self.leaderConfig = utils.readJSON(os.path.join (self.configDir, self.configFile ))
            print "Leader config updated..."
        else:
            self.createFromSample("leader")
            self.leaderConfig = utils.readJSON(os.path.join (self.configDir, self.configFile ))
            print "Leader config updated..."


        if os.path.exists(os.path.join(self.configDir, self.baseConfigFile )):
            self.config = utils.readJSON(os.path.join(self.configDir, self.baseConfigFile))
            print "Base config updated..."
        else:
            self.createFromSample("main")
            self.config = utils.readJSON(os.path.join(self.configDir, self.baseConfigFile))
            print "Base config updated..."

        # [TODO] start messengers for each worker and clients available.


        pass
示例#2
0
文件: sqdHelper.py 项目: ajZiiiN/sqd
    def __init__(self):
        # Initializes squirrel daemon with necessary information
        # ---
        self.gameId = -1
        # store in config

        self.configFile = "configC.json"
        self.configDir = "/etc/sqd"
        self.baseConfigFile = "config.json"

        self.config = dict()
        self.clientConfig = dict()
        self.msgObj = None # This is msgServer, initialized when we start the worker

        self.jobMap = {
            "iamClient" : self.iamClient
        }

        if utils.checkCreateDir (self.configDir):
            if not os.path.exists(os.path.join(self.configDir, self.configFile )) \
                    and not os.path.exists(os.path.join(self.configDir, self.baseConfigFile )) :
                self.createFromSample("all")
                print "Config created from sample..."
            else:
                print "Configs are messed up, please check and clean. "


        if os.path.exists (os.path.join (self.configDir, self.configFile )):
            self.clientConfig = utils.readJSON(os.path.join (self.configDir, self.configFile ))
            print "Client config updated..."
        else:
            self.createFromSample("client")
            self.clientConfig = utils.readJSON(os.path.join (self.configDir, self.configFile ))
            print "Client config updated from sample..."

        if os.path.exists(os.path.join(self.configDir, self.baseConfigFile )):
            self.config = utils.readJSON(os.path.join(self.configDir, self.baseConfigFile))
            print "Base config updated..."
        else:
            self.createFromSample("main")
            self.config = utils.readJSON(os.path.join(self.configDir, self.baseConfigFile))
            print "Base config updated from sample...."

        pass
示例#3
0
文件: sqdHelper.py 项目: ajZiiiN/sqd
    def __init__(self):
        self.configFile = "configW.json"
        self.configDir = "/etc/sqd"
        self.baseConfigFile = "config.json"

        self.config = dict()
        self.workerConfig = dict()
        self.msgObj = None # This is msgServer, initialized when we start the worker

        self.jobMap = {
            "addToCluster" : self.addToCluster,
            "iamAlive" : self.iamAlive,
            "addClient": self.addClient
        }

        if utils.checkCreateDir (self.configDir):
            if not os.path.exists(os.path.join(self.configDir, self.configFile )) \
                    and not os.path.exists(os.path.join(self.configDir, self.baseConfigFile )) :
                self.createFromSample("all")
                print "Config created from sample..."
            else:
                print "Configs are messed up, please check and clean. "


        if os.path.exists (os.path.join (self.configDir, self.configFile )):
            self.workerConfig = utils.readJSON(os.path.join (self.configDir, self.configFile ))
            print "Worker config updated..."
        else:
            self.createFromSample("worker")
            self.workerConfig = utils.readJSON(os.path.join (self.configDir, self.configFile ))
            print "Worker config updated from sample..."

        if os.path.exists(os.path.join(self.configDir, self.baseConfigFile )):
            self.config = utils.readJSON(os.path.join(self.configDir, self.baseConfigFile))
            print "Base config updated..."
        else:
            self.createFromSample("main")
            self.config = utils.readJSON(os.path.join(self.configDir, self.baseConfigFile))
            print "Base config updated from sample...."

        pass