made a unique toucher file
This commit is contained in:
parent
8aa11f7e8c
commit
0e91188939
2 changed files with 15 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
||||||
import os
|
import os
|
||||||
from os.path import join
|
from os.path import join, basename, dirname
|
||||||
|
|
||||||
from media.monitor.exceptions import NoConfigFile
|
from media.monitor.exceptions import NoConfigFile
|
||||||
from media.monitor.pure import LazyProperty
|
from media.monitor.pure import LazyProperty
|
||||||
|
@ -39,6 +39,14 @@ class AirtimeInstance(object):
|
||||||
if isinstance(sig, SignalString): return sig
|
if isinstance(sig, SignalString): return sig
|
||||||
else: return SignalString("%s_%s" % (self.name, sig))
|
else: return SignalString("%s_%s" % (self.name, sig))
|
||||||
|
|
||||||
|
def touch_file_path(self):
|
||||||
|
""" Get the path of the touch file for every instance """
|
||||||
|
touch_base_path = self.mm_config['index-path']
|
||||||
|
touch_base_name = basename(touch_base_path)
|
||||||
|
new_base_name = self.name + touch_base_name
|
||||||
|
return join(dirname(touch_base_path), new_base_name)
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s,%s(%s)" % (self.name, self.root_path, self.config_paths)
|
return "%s,%s(%s)" % (self.name, self.root_path, self.config_paths)
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,9 @@ class MM2(InstanceThread, Loggable):
|
||||||
manager = Manager()
|
manager = Manager()
|
||||||
apiclient = apc()
|
apiclient = apc()
|
||||||
config = user().mm_config
|
config = user().mm_config
|
||||||
watch_syncer = WatchSyncer(signal=getsig('watch'),
|
WatchSyncer(signal=getsig('watch'),
|
||||||
chunking_number=config['chunking_number'],
|
chunking_number=config['chunking_number'],
|
||||||
timeout=config['request_max_wait'])
|
timeout=config['request_max_wait'])
|
||||||
airtime_receiver = AirtimeMessageReceiver(config,manager)
|
airtime_receiver = AirtimeMessageReceiver(config,manager)
|
||||||
airtime_notifier = AirtimeNotifier(config, airtime_receiver)
|
airtime_notifier = AirtimeNotifier(config, airtime_receiver)
|
||||||
|
|
||||||
|
@ -75,15 +75,15 @@ class MM2(InstanceThread, Loggable):
|
||||||
airtime_receiver.new_watch({ 'directory':watch_dir }, restart=True)
|
airtime_receiver.new_watch({ 'directory':watch_dir }, restart=True)
|
||||||
else: self.logger.info("Failed to add watch on %s" % str(watch_dir))
|
else: self.logger.info("Failed to add watch on %s" % str(watch_dir))
|
||||||
|
|
||||||
ed = EventDrainer(airtime_notifier.connection,
|
EventDrainer(airtime_notifier.connection,
|
||||||
interval=float(config['rmq_event_wait']))
|
interval=float(config['rmq_event_wait']))
|
||||||
|
|
||||||
# Launch the toucher that updates the last time when the script was
|
# Launch the toucher that updates the last time when the script was
|
||||||
# ran every n seconds.
|
# ran every n seconds.
|
||||||
# TODO : verify that this does not interfere with bootstrapping because the
|
# TODO : verify that this does not interfere with bootstrapping because the
|
||||||
# toucher thread might update the last_ran variable too fast
|
# toucher thread might update the last_ran variable too fast
|
||||||
tt = ToucherThread(path=config['index_path'],
|
ToucherThread(path=user().touch_file_path(),
|
||||||
interval=int(config['touch_interval']))
|
interval=int(config['touch_interval']))
|
||||||
|
|
||||||
apiclient.register_component('media-monitor')
|
apiclient.register_component('media-monitor')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue