Allow configuring datasync watcher kwargs

This commit is contained in:
Lance Edgar 2022-08-21 15:22:29 -05:00
parent 87cced1637
commit 7b2fef5f09
3 changed files with 209 additions and 15 deletions

View file

@ -86,10 +86,10 @@ class WebsocketView(object):
# use given db session, or make a new one
with app.short_session(config=self.rattail_config,
session=session):
session=session) as s:
# load user proper
return session.query(model.User).get(user_uuid)
return s.query(model.User).get(user_uuid)
def get_user_session(self, scope):
settings = self.registry.settings

View file

@ -202,6 +202,9 @@ class DataSyncThreadView(MasterView):
'watcher_retry_delay': profile.watcher.retry_delay,
'watcher_default_runas': profile.watcher.default_runas,
'watcher_consumes_self': profile.watcher.consumes_self,
'watcher_kwargs_data': [{'key': key,
'value': profile.watcher_kwargs[key]}
for key in sorted(profile.watcher_kwargs)],
# 'notes': None, # TODO
'enabled': profile.enabled,
}
@ -227,8 +230,7 @@ class DataSyncThreadView(MasterView):
return {
'profiles': profiles,
'profiles_data': profiles_data,
'use_profile_settings': self.rattail_config.getbool(
'rattail.datasync', 'use_profile_settings'),
'use_profile_settings': self.datasync_handler.should_use_profile_settings(),
'supervisor_process_name': self.rattail_config.get(
'rattail.datasync', 'supervisor_process_name'),
'restart_command': self.rattail_config.get(
@ -265,6 +267,13 @@ class DataSyncThreadView(MasterView):
'value': profile['watcher_default_runas']},
])
for kwarg in profile['watcher_kwargs_data']:
settings.append({
'name': 'rattail.datasync.{}.watcher.kwarg.{}'.format(
pkey, kwarg['key']),
'value': kwarg['value'],
})
consumers = []
if profile['watcher_consumes_self']:
consumers = ['self']
@ -298,11 +307,13 @@ class DataSyncThreadView(MasterView):
settings.append({'name': 'rattail.datasync.watch',
'value': ', '.join(watch)})
settings.append({'name': 'rattail.datasync.supervisor_process_name',
'value': data['supervisor_process_name']})
if data['supervisor_process_name']:
settings.append({'name': 'rattail.datasync.supervisor_process_name',
'value': data['supervisor_process_name']})
settings.append({'name': 'tailbone.datasync.restart',
'value': data['restart_command']})
if data['restart_command']:
settings.append({'name': 'tailbone.datasync.restart',
'value': data['restart_command']})
return settings