def setup(self): # load config file if self.config_file: Config.ACTUAL_CONFIG_FILE = self.config_file else: self.config_file = Config.DEFAULT_CONFIG_FILE if self.section: Config.SECTION_NAME = self.section self.cfg = Config(self.section) if isinstance(self.cfg.daemonize, basestring): self.daemonize = str2bool(self.cfg.daemonize) if self.cfg.log_file is not None: self.log_file = self.cfg.log_file if self.cfg.pidfile is not None: self.pidfile = Pidfile(self.cfg.pidfile) self.master_name = "master: %s" % self.cfg.proc_name if self.cfg.number_workers: self.number_workers = int(self.cfg.number_workers) if self.cfg.graceful_timeout: self.graceful_timeout = float(self.cfg.graceful_timeout) if self.cfg.user: user = self.cfg.user.split(':') if len(user) <= 1: user[1] = user[0] self.uid, self.gid = get_user_info(*user[:2]) else: # set as default self.uid, self.gid = os.getuid(), os.getgid() if self.cfg.bind: binds = [] for b in self.cfg.bind.split(','): addr = b.strip().split(':') binds.append((addr[0], int(addr[1]))) self.bind = binds # self.bind = [tuple(b.strip().split(":")) for b in self.cfg.bind.split(',')] # bind address comma separate else: self.bind = None self.unix_socket = self.cfg.unix_socket if self.cfg.kill_interval: self.kill_interval = int(self.cfg.kill_interval) else: self.kill_interval = 0