blob: 10034fe58096cb3d03c2a0d09db6ecac95a6af20 [file] [log] [blame]
Marek Szwalkiewiczbe4c4642020-01-30 13:49:18 +00001"""Copyright 2019 Deutsche Telekom.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14"""
15
16from concurrent.futures import ThreadPoolExecutor
17
18import click
19from grpc import server as grpc_server
20from manager.configuration import config
21from manager.servicer import ArtifactManagerServicer
KAPIL SINGALadcd4f22021-01-22 11:49:51 -050022from proto.BlueprintManagement_pb2_grpc import add_BlueprintManagementServiceServicer_to_server
Marek Szwalkiewiczbe4c4642020-01-30 13:49:18 +000023
24
25@click.command()
26def run_server():
27 """Run Artifact Manager gRPC server.
28
29 Values like 'maxWorkers' and 'port' must be specified in a config file in .ini format.
30
31 Config file path is specified by 'CONFIGURATION' environment variable.
32
33 """
34 max_workers: int = int(config["artifactManagerServer"]["maxWorkers"])
35 server: grpc_server = grpc_server(ThreadPoolExecutor(max_workers=max_workers))
36
KAPIL SINGALadcd4f22021-01-22 11:49:51 -050037 add_BlueprintManagementServiceServicer_to_server(ArtifactManagerServicer(), server)
Marek Szwalkiewiczbe4c4642020-01-30 13:49:18 +000038 port_number: int = int(config["artifactManagerServer"]["port"])
39 server.add_insecure_port(f"[::]:{port_number}")
40
41 click.echo(f"Server starts on port {port_number} using {max_workers} workers.")
42 server.start()
43 server.wait_for_termination()
44
45
46if __name__ == "__main__":
47 run_server()