This repository has been archived by the owner on Sep 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
39 lines (30 loc) · 1.9 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
#!/usr/bin/env python3
import sys
from rest.api.constants.env_constants import EnvConstants
from rest.api.eureka_registrator import EurekaRegistrator
from rest.api.loghelpers.message_dumper import MessageDumper
from rest.api.routes import app, fluentd_service
from rest.environment.environment import EnvironmentSingleton
from rest.utils.env_startup import EnvStartupSingleton
if __name__ == "__main__":
cli = sys.modules['flask.cli']
cli.show_server_banner = lambda *x: None
port = EnvStartupSingleton.get_instance().get_config_env_vars().get(EnvConstants.PORT)
message_dumper = MessageDumper()
host = '0.0.0.0'
fluentd_tag = "startup"
if EnvStartupSingleton.get_instance().get_config_env_vars().get(EnvConstants.EUREKA_SERVER):
EurekaRegistrator(
EnvStartupSingleton.get_instance().get_config_env_vars().get(EnvConstants.EUREKA_SERVER)).register_app(
EnvStartupSingleton.get_instance().get_config_env_vars().get(EnvConstants.APP_IP),
EnvStartupSingleton.get_instance().get_config_env_vars().get(EnvConstants.PORT))
environ_dump = message_dumper.dump_message(EnvironmentSingleton.get_instance().get_env_and_virtual_env())
ip_port_dump = message_dumper.dump_message({"host": host, "port": port})
app.logger.debug({"msg": environ_dump})
app.logger.debug({"msg": ip_port_dump})
app.logger.debug({"msg": EnvStartupSingleton.get_instance().get_config_env_vars()})
fluentd_service.emit(tag=fluentd_tag, msg=environ_dump)
is_https = EnvStartupSingleton.get_instance().get_config_env_vars().get(EnvConstants.HTTPS_ENABLE)
https_cert_path = EnvStartupSingleton.get_instance().get_config_env_vars().get(EnvConstants.HTTPS_CERT)
https_prv_key_path = EnvStartupSingleton.get_instance().get_config_env_vars().get(EnvConstants.HTTPS_KEY)
app.run(host=host, port=port, ssl_context=(https_cert_path, https_prv_key_path) if is_https else None)