-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
43 lines (35 loc) · 1.01 KB
/
main.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
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import redis
from runtime import DockerRuntime
from engine import Engine
from helper import Config, log
CONF = Config("./kubeleet.conf")
PENDING_QUEUE = CONF.get("redis", "pending_queue")
RUNNING_QUEUE = CONF.get("redis", "running_queue")
CONTAINERS_SET = CONF.get("redis", "containers_set")
if CONF.has_option("redis", "password"):
REDIS_PASSWORD = CONF.get("redis", "password")
else:
REDIS_PASSWORD = None
REDIS = redis.Redis(
host=CONF.get("redis", "host"),
port=CONF.get("redis", "port"),
db=CONF.getint("redis", "db"),
password=REDIS_PASSWORD,
decode_responses=True,
)
def main():
""" Init. function of kubeleet. """
docker_runtime = DockerRuntime()
engine = Engine(
runtime=docker_runtime,
redis=REDIS,
pending_queue=PENDING_QUEUE,
running_queue=RUNNING_QUEUE,
containers_set=CONTAINERS_SET,
)
log("Starting listening for events...")
engine.start()
if __name__ == "__main__":
main()