Skip to content

Commit

Permalink
Enable faulthandler if config.debugger is set
Browse files Browse the repository at this point in the history
  • Loading branch information
steersbob committed Jan 24, 2024
1 parent c83a433 commit f3db3a7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
8 changes: 8 additions & 0 deletions brewblox_history/app_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ def create_app() -> FastAPI:
config = utils.get_config()
setup_logging(config.debug)

if config.debugger: # pragma: no cover
import faulthandler
faulthandler.enable()

import debugpy
debugpy.listen(('0.0.0.0', 5678))
LOGGER.info('Debugger is enabled and listening on 5678')

# Call setup functions for modules
mqtt.setup()
redis.setup()
Expand Down
1 change: 1 addition & 0 deletions brewblox_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ServiceConfig(BaseSettings):

name: str = 'history'
debug: bool = False
debugger: bool = False

mqtt_protocol: Literal['mqtt', 'mqtts'] = 'mqtt'
mqtt_host: str = 'eventbus'
Expand Down
29 changes: 28 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pydantic-settings = "^2.1.0"
fastapi-mqtt = "^2.0.0"
httpx = "^0.25.2"
websockets = "^12.0"
debugpy = "^1.8.0"

[tool.poetry.group.dev.dependencies]
pytest-cov = "*"
Expand Down

0 comments on commit f3db3a7

Please sign in to comment.