mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-14 23:24:30 -04:00
add new archivebox worker implementation based on better distributed systems principles
This commit is contained in:
parent
a859278a63
commit
5cf7725f0e
2 changed files with 481 additions and 0 deletions
33
archivebox/cli/archivebox_worker.py
Normal file
33
archivebox/cli/archivebox_worker.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
__package__ = 'archivebox.cli'
|
||||
__command__ = 'archivebox worker'
|
||||
|
||||
import sys
|
||||
import json
|
||||
|
||||
import rich_click as click
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument('worker_type')
|
||||
@click.option('--wait-for-first-event', is_flag=True)
|
||||
@click.option('--exit-on-idle', is_flag=True)
|
||||
def main(worker_type: str, wait_for_first_event: bool, exit_on_idle: bool):
|
||||
"""Start an ArchiveBox worker process of the given type"""
|
||||
|
||||
from workers.worker import get_worker_type
|
||||
|
||||
# allow piping in events to process from stdin
|
||||
# if not sys.stdin.isatty():
|
||||
# for line in sys.stdin.readlines():
|
||||
# Event.dispatch(event=json.loads(line), parent=None)
|
||||
|
||||
# run the actor
|
||||
Worker = get_worker_type(worker_type)
|
||||
for event in Worker.run(wait_for_first_event=wait_for_first_event, exit_on_idle=exit_on_idle):
|
||||
print(event)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue