removed old runner code
This commit is contained in:
parent
8a7535774c
commit
0b0e96f49c
|
@ -64,88 +64,6 @@ def main(global_config, api_client_config, log_config):
|
||||||
mm = MM2(ai)
|
mm = MM2(ai)
|
||||||
mm.start()
|
mm.start()
|
||||||
|
|
||||||
def main2(global_config, api_client_config, log_config,
|
|
||||||
index_create_attempt=False):
|
|
||||||
for cfg in [global_config, api_client_config]:
|
|
||||||
if not os.path.exists(cfg): raise NoConfigFile(cfg)
|
|
||||||
# MMConfig is a proxy around ConfigObj instances. it does not allow
|
|
||||||
# itself users of MMConfig instances to modify any config options
|
|
||||||
# directly through the dictionary. Users of this object must use the
|
|
||||||
# correct methods designated for modification
|
|
||||||
try: config = MMConfig(global_config)
|
|
||||||
except NoConfigFile as e:
|
|
||||||
print("Cannot run mediamonitor2 without configuration file.")
|
|
||||||
print("Current config path: '%s'" % global_config)
|
|
||||||
sys.exit(1)
|
|
||||||
except Exception as e:
|
|
||||||
print("Unknown error reading configuration file: '%s'" % global_config)
|
|
||||||
print(str(e))
|
|
||||||
|
|
||||||
log = setup_logger( log_config, config['logpath'] )
|
|
||||||
|
|
||||||
if not index_create_attempt:
|
|
||||||
if not os.path.exists(config['index_path']):
|
|
||||||
log.info("Attempting to create index file:...")
|
|
||||||
try:
|
|
||||||
with open(config['index_path'], 'w') as f: f.write(" ")
|
|
||||||
except Exception as e:
|
|
||||||
log.info("Failed to create index file with exception: %s" \
|
|
||||||
% str(e))
|
|
||||||
else:
|
|
||||||
log.info("Created index file, reloading configuration:")
|
|
||||||
main( global_config, api_client_config, log_config,
|
|
||||||
index_create_attempt=True )
|
|
||||||
else:
|
|
||||||
log.info("Already tried to create index. Will not try again ")
|
|
||||||
|
|
||||||
if not os.path.exists(config['index_path']):
|
|
||||||
log.info("Index file does not exist. Terminating")
|
|
||||||
|
|
||||||
setup_global(log)
|
|
||||||
|
|
||||||
watch_syncer = WatchSyncer(signal='watch',
|
|
||||||
chunking_number=config['chunking_number'],
|
|
||||||
timeout=config['request_max_wait'])
|
|
||||||
|
|
||||||
apiclient = apc.AirtimeApiClient.create_right_config(log=log,
|
|
||||||
config_path=api_client_config)
|
|
||||||
|
|
||||||
manager = Manager()
|
|
||||||
|
|
||||||
airtime_receiver = AirtimeMessageReceiver(config,manager)
|
|
||||||
airtime_notifier = AirtimeNotifier(config, airtime_receiver)
|
|
||||||
|
|
||||||
store = apiclient.setup_media_monitor()
|
|
||||||
|
|
||||||
log.info("Initing with the following airtime response:%s" % str(store))
|
|
||||||
|
|
||||||
airtime_receiver.change_storage({ 'directory':store[u'stor'] })
|
|
||||||
|
|
||||||
for watch_dir in store[u'watched_dirs']:
|
|
||||||
if not os.path.exists(watch_dir):
|
|
||||||
# Create the watch_directory here
|
|
||||||
try: os.makedirs(watch_dir)
|
|
||||||
except Exception as e:
|
|
||||||
log.error("Could not create watch directory: '%s' \
|
|
||||||
(given from the database)." % watch_dir)
|
|
||||||
if os.path.exists(watch_dir):
|
|
||||||
airtime_receiver.new_watch({ 'directory':watch_dir }, restart=True)
|
|
||||||
else: log.info("Failed to add watch on %s" % str(watch_dir))
|
|
||||||
|
|
||||||
ed = EventDrainer(airtime_notifier.connection,
|
|
||||||
interval=float(config['rmq_event_wait']))
|
|
||||||
|
|
||||||
# Launch the toucher that updates the last time when the script was
|
|
||||||
# ran every n seconds.
|
|
||||||
# TODO : verify that this does not interfere with bootstrapping because the
|
|
||||||
# toucher thread might update the last_ran variable too fast
|
|
||||||
tt = ToucherThread(path=config['index_path'],
|
|
||||||
interval=int(config['touch_interval']))
|
|
||||||
|
|
||||||
apiclient.register_component('media-monitor')
|
|
||||||
|
|
||||||
return manager.loop()
|
|
||||||
|
|
||||||
__doc__ = """
|
__doc__ = """
|
||||||
Usage:
|
Usage:
|
||||||
mm2.py --config=<path> --apiclient=<path> --log=<path>
|
mm2.py --config=<path> --apiclient=<path> --log=<path>
|
||||||
|
|
Loading…
Reference in New Issue