def run(self):
'''Main execute of the class'''
def cb_exit_gracefully(signum, frame):
'''Callback to exit gracefully'''
self.logger.info("Grace exit command received signum %d" % (signum))
for proc in self.current_subprocs:
if proc.poll() is None:
# Switching to a kill -9 as the nice option seems to require it.
# proc.send_signal(signal.SIGINT)
proc.terminate()
#subprocess.check_call("kill -9 " + proc.pid())
sys.exit(0)
compressor_workers = int(self.config.get("compression", "compressor_workers"))
self.logger.info("Compressor process starting up")
self.pool = ThreadPool(compressor_workers)
setproctitle("[compress] " + getproctitle())
signal.signal(signal.SIGINT, cb_exit_gracefully)
signal.signal(signal.SIGTERM, cb_exit_gracefully)
while True:
tocompress_dir = os.path.join(self.config.get(
"main", "working_directory"), "tocompress")
files = self.get_files(tocompress_dir, ".mak")
if files:
self.pool.map(self.compress_filename, files)
time.sleep(float(self.config.get(
"compression", "compression_check_interval")))
sys.exit(0)
评论列表
文章目录