some updates
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2021-08-10 16:15:20 +02:00
parent e6afdd5bac
commit c26aa1be43
2 changed files with 28 additions and 17 deletions

View File

@ -21,21 +21,6 @@ __copyright__ = "Copyright 2020, Birbnetes Team"
__module_name__ = "app" __module_name__ = "app"
__version__text__ = "1" __version__text__ = "1"
if config.SENTRY_DSN:
sentry_logging = LoggingIntegration(
level=logging.DEBUG, # Capture info and above as breadcrumbs
event_level=logging.ERROR # Send errors as events
)
sentry_sdk.init(
dsn=config.SENTRY_DSN,
send_default_pii=True,
integrations=[sentry_logging],
traces_sample_rate=1.0,
release=config.RELEASE_ID,
environment=config.RELEASEMODE,
_experiments={"auto_enabling_integrations": True}
)
def setup_rabbit(mqtt_: MQTT) -> None: def setup_rabbit(mqtt_: MQTT) -> None:
logging.info("Connecting to RabbitMQ...") logging.info("Connecting to RabbitMQ...")
@ -118,11 +103,25 @@ def on_message_creator(mqtt_: MQTT):
return on_message return on_message
if __name__ == "__main__": def main():
logging.basicConfig( logging.basicConfig(
stream=sys.stdout, stream=sys.stdout,
format="%(asctime)s - %(name)s [%(levelname)s]: %(message)s", format="%(asctime)s - %(name)s [%(levelname)s]: %(message)s",
level=logging.DEBUG if '--debug' in sys.argv else logging.INFO level=config.LOG_LEVEL
)
if config.SENTRY_DSN:
sentry_logging = LoggingIntegration(
level=logging.DEBUG, # Capture info and above as breadcrumbs
event_level=logging.ERROR # Send errors as events
)
sentry_sdk.init(
dsn=config.SENTRY_DSN,
send_default_pii=True,
integrations=[sentry_logging],
traces_sample_rate=0.0,
release=config.RELEASE_ID,
environment=config.RELEASEMODE,
_experiments={"auto_enabling_integrations": True}
) )
logging.info("Guard service starting...") logging.info("Guard service starting...")
mqtt = MQTT() mqtt = MQTT()
@ -130,3 +129,7 @@ if __name__ == "__main__":
mqtt.connect() mqtt.connect()
mqtt.client.loop_start() # Start MQTT event loop on a different thread mqtt.client.loop_start() # Start MQTT event loop on a different thread
setup_rabbit(mqtt) setup_rabbit(mqtt)
if __name__ == "__main__":
main()

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import sys
import logging
""" """
@ -32,3 +34,9 @@ MQTT_TOPIC = os.getenv("GUARD_MQTT_TOPIC", "guard-service")
INPUT_HOSTNAME = os.getenv("INPUT_SVC_HOSTNAME", "input-service") INPUT_HOSTNAME = os.getenv("INPUT_SVC_HOSTNAME", "input-service")
INPUT_TIMEOUT = int(os.environ.get("INPUT_SVC_TIMEOUT", 5)) INPUT_TIMEOUT = int(os.environ.get("INPUT_SVC_TIMEOUT", 5))
TRIGGER_LEVEL = float(os.environ.get("TRIGGER_LEVEL", 0.51)) TRIGGER_LEVEL = float(os.environ.get("TRIGGER_LEVEL", 0.51))
LOG_LEVEL = logging.DEBUG if (
'--debug' in sys.argv
) or (
os.environ.get('DEBUG', '0').lower() in ['yes', 'true', '1']
) else logging.INFO