mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 06:34:25 -04:00
avoid auto-starting all supervisord workers on startup
This commit is contained in:
parent
8d1d5df43a
commit
d680c48942
2 changed files with 16 additions and 7 deletions
|
@ -77,12 +77,16 @@ class BaseHook(BaseModel):
|
||||||
"""e.g. builtin_plugins.singlefile.apps.SinglefileConfigSet"""
|
"""e.g. builtin_plugins.singlefile.apps.SinglefileConfigSet"""
|
||||||
return f'{self.__module__}.{self.__class__.__name__}'
|
return f'{self.__module__}.{self.__class__.__name__}'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hook_file(self) -> Path:
|
||||||
|
"""e.g. builtin_plugins.singlefile.apps.SinglefileConfigSet"""
|
||||||
|
return Path(inspect.getfile(self.__class__))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def plugin_module(self) -> str:
|
def plugin_module(self) -> str:
|
||||||
"""e.g. builtin_plugins.singlefile"""
|
"""e.g. builtin_plugins.singlefile"""
|
||||||
return f"{self.__module__}.{self.__class__.__name__}".split("archivebox.", 1)[-1].rsplit(".apps.", 1)[0]
|
return f"{self.__module__}.{self.__class__.__name__}".split("archivebox.", 1)[-1].rsplit(".apps.", 1)[0]
|
||||||
|
|
||||||
@computed_field
|
|
||||||
@property
|
@property
|
||||||
def plugin_dir(self) -> Path:
|
def plugin_dir(self) -> Path:
|
||||||
return Path(inspect.getfile(self.__class__)).parent.resolve()
|
return Path(inspect.getfile(self.__class__)).parent.resolve()
|
||||||
|
|
|
@ -77,6 +77,11 @@ class BaseQueue(BaseHook):
|
||||||
return None
|
return None
|
||||||
print()
|
print()
|
||||||
worker = start_worker(supervisor, self.get_supervisor_config(settings), lazy=lazy)
|
worker = start_worker(supervisor, self.get_supervisor_config(settings), lazy=lazy)
|
||||||
|
|
||||||
|
# Update settings.WORKERS to include this worker
|
||||||
|
settings.WORKERS = getattr(settings, "WORKERS", None) or AttrDict({})
|
||||||
|
settings.WORKERS[self.id] = self.start_supervisord_worker(settings, lazy=True)
|
||||||
|
|
||||||
return worker
|
return worker
|
||||||
|
|
||||||
def register(self, settings, parent_plugin=None):
|
def register(self, settings, parent_plugin=None):
|
||||||
|
@ -90,10 +95,6 @@ class BaseQueue(BaseHook):
|
||||||
# on_startup(queue=self.name)(self.on_startup_task)
|
# on_startup(queue=self.name)(self.on_startup_task)
|
||||||
# db_periodic_task(crontab(minute='*/5'))(self.on_periodic_task)
|
# db_periodic_task(crontab(minute='*/5'))(self.on_periodic_task)
|
||||||
|
|
||||||
# Side effect: start consumer worker process under supervisord
|
|
||||||
settings.WORKERS = getattr(settings, "WORKERS", None) or AttrDict({})
|
|
||||||
settings.WORKERS[self.id] = self.start_supervisord_worker(settings, lazy=True)
|
|
||||||
|
|
||||||
# Install queue into settings.QUEUES
|
# Install queue into settings.QUEUES
|
||||||
settings.QUEUES = getattr(settings, "QUEUES", None) or AttrDict({})
|
settings.QUEUES = getattr(settings, "QUEUES", None) or AttrDict({})
|
||||||
settings.QUEUES[self.id] = self
|
settings.QUEUES[self.id] = self
|
||||||
|
@ -101,6 +102,10 @@ class BaseQueue(BaseHook):
|
||||||
# Record installed hook into settings.HOOKS
|
# Record installed hook into settings.HOOKS
|
||||||
super().register(settings, parent_plugin=parent_plugin)
|
super().register(settings, parent_plugin=parent_plugin)
|
||||||
|
|
||||||
|
# def ready(self, settings):
|
||||||
|
# self.start_supervisord_worker(settings, lazy=True)
|
||||||
|
# super().ready(settings)
|
||||||
|
|
||||||
|
|
||||||
# class WgetToggleConfig(ConfigSet):
|
# class WgetToggleConfig(ConfigSet):
|
||||||
# section: ConfigSectionName = 'ARCHIVE_METHOD_TOGGLES'
|
# section: ConfigSectionName = 'ARCHIVE_METHOD_TOGGLES'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue