Skip to content

Commit

Permalink
Merge pull request #229 from steersbob/feature/faulthandler
Browse files Browse the repository at this point in the history
Enable faulthandler if config.debugger is set
  • Loading branch information
steersbob authored Jan 25, 2024
2 parents c83a433 + b4bc845 commit e2f9091
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 5678,
"host": "buildbot32.local",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
]
}
],
"compounds": []
}
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 e2f9091

Please sign in to comment.