forked from numaproj/numalogic-prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
starter.py
32 lines (23 loc) · 814 Bytes
/
starter.py
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
import sys
import threading
from pynumaflow.function import Server
from pynumaflow.sink import Sink
from numaprom._constants import CONFIG_PATHS
from numaprom.factory import HandlerFactory
from numaprom.watcher import Watcher, ConfigHandler
def run_watcher():
w = Watcher(CONFIG_PATHS, ConfigHandler())
w.run()
if __name__ == "__main__":
background_thread = threading.Thread(target=run_watcher, args=())
background_thread.daemon = True
background_thread.start()
step_handler = HandlerFactory.get_handler(sys.argv[2])
server_type = sys.argv[1]
if server_type == "udsink":
server = Sink(step_handler)
elif server_type == "udf":
server = Server(step_handler)
else:
raise ValueError(f"sys arg: {server_type} not understood!")
server.start()