Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions .github/workflows/python_package_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,34 @@ jobs:
container:
image: matanrubin/python-poetry:3.7

env:
TEST_REDIS_SERVER: True
REDIS_HOST: redis

services:
# User a redis container for testing the redis health-provider
redis:
image: redis:5.0.3

steps:
- uses: actions/checkout@v2
- run: make bootstrap
- run: poetry build -vvv

# Install all dependencies except for psutil and run the tests with coverage - this tests handling missing psutil
- run: poetry install --extras flask --extras fastapi --extras aiohttp --extras db --extras redis
- run: make coverage

# Run pylint+mypy after installing psutil so they don't complain on missing dependencies
- run: poetry install --extras psutil
- run: make check

# Run tests with coverage again - this adds tests that require psutil
- run: make coverage

# Upload coverage files to codecov
- uses: actions/upload-artifact@v2
with:
name: htmlcov.zip
path: htmlcov/
- uses: codecov/codecov-action@v1

# Install the extra psutil module and run linting+tests in the "psutil enabled" env
- run: poetry install --extras psutil
- run: make check
- run: make test
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test:
poetry run pytest --log-cli-level=4 -vv tests

coverage:
poetry run pytest --cov-report xml:./coverage.xml --cov-report html --cov-report term --cov=pyctuator --log-cli-level=4 -vv tests
poetry run pytest --cov-append --cov-report xml:./coverage.xml --cov-report html --cov-report term --cov=pyctuator --log-cli-level=4 -vv tests

pylint:
poetry run pylint --exit-zero pyctuator tests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Monitor Python web apps using
[Spring Boot Admin](https://github.com/codecentric/spring-boot-admin).

Pyctuator supports **Flask**, **FastAPI** and **aiohttp**. **Django** support is planned as well.
Pyctuator supports **[Flask](https://palletsprojects.com/p/flask/)**, **[FastAPI](https://fastapi.tiangolo.com/)** and **[aiohttp](docs.aiohttp.org)**. **Django** support is planned as well.

The following video shows a FastAPI web app being monitored and controled using Spring Boot Admin.

Expand Down
93 changes: 48 additions & 45 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyctuator/impl/aiohttp_pyctuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime
from functools import partial
from http import HTTPStatus
from typing import Any, Callable, List, Mapping, Optional
from typing import Any, Callable, List, Mapping

from aiohttp import web
from multidict import CIMultiDictProxy
Expand Down
5 changes: 1 addition & 4 deletions pyctuator/impl/spring_boot_admin_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ def __init__(

self.should_continue_registration_schedule: bool = False

def _schedule_next_registration(
self,
registration_interval_sec: int
) -> None:
def _schedule_next_registration(self, registration_interval_sec: int) -> None:
timer = threading.Timer(
registration_interval_sec,
self._register_with_admin_server,
Expand Down
2 changes: 1 addition & 1 deletion pyctuator/pyctuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def __init__(
return

# Fail in case no framework was found for the target app
raise EnvironmentError("No framework was found that is matching the target app"
raise EnvironmentError("No framework was found that is matching the target app "
"(is it properly installed and imported?)")

def stop(self) -> None:
Expand Down
6 changes: 6 additions & 0 deletions tests/aiohttp_test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ def start(self) -> None:
time.sleep(0.01)

def stop(self) -> None:
logging.info("Stopping aiohttp server")
self.pyctuator.stop()
self.should_stop_server = True
self.thread.join()
logging.info("aiohttp server stopped")

def atexit(self) -> None:
if self.pyctuator.boot_admin_registration_handler:
self.pyctuator.boot_admin_registration_handler.deregister_from_admin_server()
Loading