def __init__(self): """Need to set the verification directory and logging""" self.FTP_Settings = read_backend_config(self.get_id()) self.VERIFY_DIR = self.FTP_Settings["VERIFY_DIR"] self.ARCHIVE_STAGING_DIR = self.FTP_Settings["ARCHIVE_STAGING_DIR"] self.connection_pool = ConnectionPool() self.download_threads = [] self.upload_threads = [] self.delete_threads = []
def run(*args): logger = logging.getLogger() logger.setLevel(logging.DEBUG) shutdown = multiprocessing.Event() shutdown.clear() # First of all check if the process is running - if it is then don't start # running again n_procs = 0 procs = subprocess.check_output(["ps", "-f", "-u", "root"]).decode("utf-8") for l in procs.split("\n"): if "ET_transfer_mp" in l and not "/bin/sh" in l: n_procs += 1 if n_procs > 1: logging.error("Process already running, exiting") sys.exit(4) signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGHUP, signal.SIG_IGN) signal.signal(signal.SIGTERM, signal.SIG_IGN) # Limit the worker process count ET_Settings = read_backend_config("elastictape") transferNum = ET_Settings["THREADS"] for i in range(transferNum): p = TransferProcess() p.setup() processes.append(p) p.start() signal.signal(signal.SIGINT, shutdown_handler) signal.signal(signal.SIGHUP, shutdown_handler) signal.signal(signal.SIGTERM, shutdown_handler) signal.pause() for p in processes: p.stop() for p in processes: p.join() logging.debug('Process shutdown: {}'.format(p.name)) sys.exit(0)
def __init__(self): """Need to set the verification directory and archive staging directory""" self.ET_Settings = read_backend_config(self.get_id()) self.VERIFY_DIR = self.ET_Settings["VERIFY_DIR"] self.ARCHIVE_STAGING_DIR = self.ET_Settings["ARCHIVE_STAGING_DIR"]
def setup(self): self.ET_Settings = read_backend_config("elastictape") self.host = self.ET_Settings["PUT_HOST"] self.port = self.ET_Settings["PORT"] self.shutdown = multiprocessing.Event()