def run(*args): # setup the logging config = read_process_config("import_os_gws") logging.basicConfig(format=get_logging_format(), level="INFO", datefmt='%Y-%d-%m %I:%M:%S') logging.info("Starting import_os_gws") # setup exit signal handling signal.signal(signal.SIGINT, exit_handler) signal.signal(signal.SIGHUP, exit_handler) signal.signal(signal.SIGTERM, exit_handler) data = get_et_gws_from_url(config["OS_EXPORT_URL"]) # decide whether to run as a daemon arg_dict = split_args(args) if "daemon" in arg_dict: if arg_dict["daemon"].lower() == "true": daemon = True else: daemon = False else: daemon = False # run as a daemon or one shot if daemon: # loop this indefinitely until the exit signals are triggered while True: create_user_gws_quotas(data) sleep(int(config["RUN_EVERY"])) else: create_user_gws_quotas(data)
def run(*args): # setup the logging # setup exit signal handling global connection_pool config = read_process_config("jdma_transfer") logging.basicConfig(format=get_logging_format(), level=get_logging_level(config["LOG_LEVEL"]), datefmt='%Y-%d-%m %I:%M:%S') logging.info("Starting jdma_transfer") # remap signals to shutdown handler which in turn calls sys.exit(0) # and raises SystemExit exception signal.signal(signal.SIGINT, shutdown_handler) signal.signal(signal.SIGHUP, shutdown_handler) signal.signal(signal.SIGTERM, shutdown_handler) # process the arguments arg_dict = split_args(args) # create a list of backend objects to run process on # are we running one backend or many? backend_objects = [] if "backend" in arg_dict: backend = arg_dict["backend"] # one backend if not backend in jdma_control.backends.get_backend_ids(): logging.error("Backend: " + backend + " not recognised.") else: backend_class = jdma_control.backends.get_backend_from_id(backend) backend_objects.append(backend_class()) else: # all the backends for backend in jdma_control.backends.get_backends(): backend_objects.append(backend()) # decide whether to run as a daemon if "daemon" in arg_dict: if arg_dict["daemon"].lower() == "true": daemon = True else: daemon = False else: daemon = False # run as a daemon or one shot if daemon: # loop this indefinitely until the exit signals are triggered while True: run_loop(backend_objects) # add a random amount of time to prevent(?) race conditions sleep(5 + random.random()) else: run_loop(backend_objects)
def run(*args): global connection_pool config = read_process_config("jdma_monitor") logging.basicConfig( format=get_logging_format(), level=get_logging_level(config["LOG_LEVEL"]), datefmt='%Y-%d-%m %I:%M:%S' ) logging.info("Starting jdma_monitor") # monitor the backends for completed GETs and PUTs (to et) # have to monitor each backend # setup exit signal handling signal.signal(signal.SIGINT, exit_handler) signal.signal(signal.SIGHUP, exit_handler) signal.signal(signal.SIGTERM, exit_handler) # process the arguments arg_dict = split_args(args) if "backend" in arg_dict: backend = arg_dict["backend"] else: backend = None # decide whether to run as a daemon if "daemon" in arg_dict: if arg_dict["daemon"].lower() == "true": daemon = True else: daemon = False else: daemon = False # run as a daemon or one shot if daemon: # loop this indefinitely until the exit signals are triggered while True: run_loop(backend) sleep(5 + random.random()) else: run_loop(backend)
def run(*args): """Entry point for the Django script run via ``./manage.py runscript`` optionally pass the backend_id in as an argument """ config = read_process_config("jdma_lock") logging.basicConfig( format=get_logging_format(), level=get_logging_level(config["LOG_LEVEL"]), datefmt='%Y-%d-%m %I:%M:%S' ) logging.info("Starting jdma_lock") # setup exit signal handling signal.signal(signal.SIGINT, exit_handler) signal.signal(signal.SIGHUP, exit_handler) signal.signal(signal.SIGTERM, exit_handler) # process the arguments arg_dict = split_args(args) if "backend" in arg_dict: backend = arg_dict["backend"] else: backend = None # decide whether to run as a daemon if "daemon" in arg_dict: if arg_dict["daemon"].lower() == "true": daemon = True else: daemon = False else: daemon = False # run as a daemon or one shot if daemon: # loop this indefinitely until the exit signals are triggered while True: run_loop(backend, config) sleep(5 + random.random()) else: run_loop(backend, config)