|
1
|
|
|
""" |
|
2
|
|
|
OCR-D CLI: start the processing server |
|
3
|
|
|
|
|
4
|
|
|
.. click:: ocrd.cli.processing_server:processing_server_cli |
|
5
|
|
|
:prog: ocrd processing-server |
|
6
|
|
|
:nested: full |
|
7
|
|
|
""" |
|
8
|
|
|
import click |
|
9
|
|
|
import logging |
|
10
|
|
|
from ocrd_utils import initLogging |
|
11
|
|
|
from ocrd_network import ( |
|
12
|
|
|
ProcessingServer, |
|
13
|
|
|
ProcessingServerParamType |
|
14
|
|
|
) |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
@click.command('processing-server') |
|
18
|
|
|
@click.argument('path_to_config', required=True, type=click.STRING) |
|
19
|
|
|
@click.option('-a', '--address', |
|
20
|
|
|
default="localhost:8080", |
|
21
|
|
|
help='The URL of the Processing server, format: host:port', |
|
22
|
|
|
type=ProcessingServerParamType(), |
|
23
|
|
|
required=True) |
|
24
|
|
|
def processing_server_cli(path_to_config, address: str): |
|
25
|
|
|
""" |
|
26
|
|
|
Start and manage processing workers with the processing server |
|
27
|
|
|
|
|
28
|
|
|
PATH_TO_CONFIG is a yaml file to configure the server and the workers. See |
|
29
|
|
|
https://github.com/OCR-D/spec/pull/222/files#diff-a71bf71cbc7d9ce94fded977f7544aba4df9e7bdb8fc0cf1014e14eb67a9b273 |
|
30
|
|
|
for further information (TODO: update path when spec is available/merged) |
|
31
|
|
|
|
|
32
|
|
|
""" |
|
33
|
|
|
initLogging() |
|
34
|
|
|
# TODO: Remove before the release |
|
35
|
|
|
logging.getLogger('paramiko.transport').setLevel(logging.INFO) |
|
36
|
|
|
logging.getLogger('ocrd.network').setLevel(logging.DEBUG) |
|
37
|
|
|
|
|
38
|
|
|
# Note, the address is already validated with the type field |
|
39
|
|
|
host, port = address.split(':') |
|
40
|
|
|
processing_server = ProcessingServer(path_to_config, host, port) |
|
41
|
|
|
processing_server.start() |
|
42
|
|
|
|