-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
65 lines (53 loc) · 1.99 KB
/
Copy pathtest.py
File metadata and controls
65 lines (53 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import logging
from concurrent import futures
import grpc
import trial_1_pb2_grpc
from time import sleep
import threading
class Server(trial_1_pb2_grpc.AlertServicer):
def __init__(self):
self.IP_addr_end = "localhost"
self.containers_and_load = {}
self.first_run = True
self.load_balancing_type = 4
self.round_robin_index = 0
def serve1():
sleep(5)
# Initialising the connector server
logger.debug("Initialising the connector server...")
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
logger.debug("Added multithreading to the connector server...")
trial_1_pb2_grpc.add_AlertServicer_to_server(Server(), server)
logger.debug("Initialised the connector server object...")
port = 50050
# Starting the server
server.add_insecure_port("[::]:" + str(port))
server.start()
print("Server started listening on port " + str(port) + "...")
logger.debug("Server started listening on port " + str(port) + "...")
server.wait_for_termination()
def serve2():
# Initialising the connector server
logger.debug("Initialising the connector server...")
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
logger.debug("Added multithreading to the connector server...")
trial_1_pb2_grpc.add_AlertServicer_to_server(Server(), server)
logger.debug("Initialised the connector server object...")
port = 40040
# Starting the server
server.add_insecure_port("[::]:" + str(port))
threading.Thread(target=serve1).start()
server.start()
print("Server started listening on port " + str(port) + "...")
logger.debug("Server started listening on port " + str(port) + "...")
server.wait_for_termination()
if __name__ == "__main__":
# Intitialising the logger
logging.basicConfig(
filename="scaler.log",
format="%(asctime)s %(message)s",
filemode="w",
)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
serve2()