Пример #1
0
    def __init__(self, path="/etc/GSMT",  # pylint: disable=r0913
                 verbose=False, foreground=False,
                 servers_path="/opt/GSMT",
                 adress=Adress("localhost", 8000),
                 system_user=SystemUser(None, None)):
        """Init :class DaemonizeWithXMLRPC:.

        If path does not exists create it.
        If verbose create logger to stdout.

        -**parameters**, **types**, **return** and **return types**

            :param str path: Path for config, db and pidfile.
            :param boolean verbose: Lower log level to DEBUG.
            :param boolean foreground: If True app stays in foreground and
                redirect the output to stdout.
            :param str servers_path: Path to servers default directory
            :param Adress adress: Port and Adress for XMLRPC.
            :param SystemUser system_user: User and group for gsmt-daemon.
        """
        mkdir_p(path)  # Create dir when not exists
        self.pid = os.path.join(path, "GSMT.pid")
        self.path = path
        self.servers_path = servers_path

        self.logger = _init_stdout_logger() if foreground else None

        self.adress = adress
        self.system_user = system_user

        self._init_servers()

        self.daemonize = DaemonizeNoTraceback(
            app="GSMT", pid=self.pid, user=self.system_user.user, group=self.system_user.group,
            verbose=verbose, logger=self.logger, action=self.main, foreground=foreground)
Пример #2
0
    def __init__(self, name, logger, config, path, buffsize=100):
        """Init game_server.

        -**parameters**, **types**, **return** and **return types**

            :param str name: Name of server director and is also used for
             generating default path to the server.
            :param Logger logger: Instance of logger.
            :param ConfigParse config: Instance of section within the config
             parse.
            :param str path: Path to the server directory.
            :param int buffsize: Number of recent lines to be stored.
        """
        self.name = name
        self.logger = logger
        self.config = config
        self.path = path
        self.stdin_deque = deque(maxlen=buffsize)
        self.stdout_deque = deque(maxlen=buffsize)
        self.stderr_deque = deque(maxlen=buffsize)

        mkdir_p(path)

        self.logger.debug("Initialized server \"%s\" on path \"%s\"." % (name, path))