def daemon(self): RebuilddLog.info("Starting rebuildd %s" % __version__) self.daemonize() # Run the network server thread RebuilddLog.info("Launching network server") self.netserv = RebuilddNetworkServer(self) self.netserv.setDaemon(True) self.netserv.start() # Run main loop RebuilddLog.info("Running main loop") self.loop() # On exit RebuilddLog.info("Cleaning finished and canceled jobs") self.clean_jobs() RebuilddLog.info("Stopping all jobs") self.stop_all_jobs() RebuilddLog.info("Releasing wait-locked jobs") self.release_jobs() self.netserv.join(10) RebuilddLog.info("Exiting rebuildd")
class Rebuildd(object): jobs = [] _instance = None def __new__(cls): if cls._instance is None: cls._instance = object.__new__(cls) cls._instance.init() return cls._instance def init(self): self.cfg = RebuilddConfig() # Init log system RebuilddLog() self._sqlconnection = sqlobject.connectionForURI(self.cfg.get('build', 'database_uri')) sqlobject.sqlhub.processConnection = self._sqlconnection # Create distributions for dist in self.cfg.get('build', 'dists').split(' '): for arch in self.cfg.arch: Dists().add_dist(Distribution(dist, arch)) self.do_quit = threading.Event() self.jobs_locker = threading.Lock() self.job_finished = threading.Event() def daemon(self): RebuilddLog.info("Starting rebuildd %s" % __version__) self.daemonize() # Run the network server thread RebuilddLog.info("Launching network server") self.netserv = RebuilddNetworkServer(self) self.netserv.setDaemon(True) self.netserv.start() # Run main loop RebuilddLog.info("Running main loop") self.loop() # On exit RebuilddLog.info("Cleaning finished and canceled jobs") self.clean_jobs() RebuilddLog.info("Stopping all jobs") self.stop_all_jobs() RebuilddLog.info("Releasing wait-locked jobs") self.release_jobs() self.netserv.join(10) RebuilddLog.info("Exiting rebuildd") def daemonize(self): """Do daemon stuff""" signal.signal(signal.SIGTERM, self.handle_sigterm) signal.signal(signal.SIGINT, self.handle_sigterm) try: os.chdir(self.cfg.get('build', 'work_dir')) except Exception, error: print "E: unable to chdir to work_dir: %s" % error sys.exit(1) try: sys.stdout = sys.stderr = file(self.cfg.get('log', 'file'), "a") except Exception, error: print "E: unable to open logfile: %s" % error
class Rebuildd(object): jobs = [] _instance = None def __new__(cls): if cls._instance is None: cls._instance = object.__new__(cls) cls._instance.init() return cls._instance def init(self): self.cfg = RebuilddConfig() # Init log system RebuilddLog() self._sqlconnection = sqlobject.connectionForURI( self.cfg.get('build', 'database_uri')) sqlobject.sqlhub.processConnection = self._sqlconnection # Create distributions for dist in self.cfg.get('build', 'dists').split(' '): for arch in self.cfg.arch: Dists().add_dist(Distribution(dist, arch)) self.do_quit = threading.Event() self.jobs_locker = threading.Lock() self.job_finished = threading.Event() def daemon(self): RebuilddLog.info("Starting rebuildd %s" % __version__) self.daemonize() # Run the network server thread RebuilddLog.info("Launching network server") self.netserv = RebuilddNetworkServer(self) self.netserv.setDaemon(True) self.netserv.start() # Run main loop RebuilddLog.info("Running main loop") self.loop() # On exit RebuilddLog.info("Cleaning finished and canceled jobs") self.clean_jobs() RebuilddLog.info("Stopping all jobs") self.stop_all_jobs() RebuilddLog.info("Releasing wait-locked jobs") self.release_jobs() self.netserv.join(10) RebuilddLog.info("Exiting rebuildd") def daemonize(self): """Do daemon stuff""" signal.signal(signal.SIGTERM, self.handle_sigterm) signal.signal(signal.SIGINT, self.handle_sigterm) try: os.chdir(self.cfg.get('build', 'work_dir')) except Exception, error: print "E: unable to chdir to work_dir: %s" % error sys.exit(1) try: sys.stdout = sys.stderr = file(self.cfg.get('log', 'file'), "a") except Exception, error: print "E: unable to open logfile: %s" % error