Skip to content

Commit cf01e44

Browse files
author
michaelyaakoby
authored
Merge pull request #37 from SolarEdgeTech/tornado
Tornado
2 parents a4c9dda + 808f488 commit cf01e44

File tree

17 files changed

+569
-152
lines changed

17 files changed

+569
-152
lines changed

.github/workflows/python_package_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- run: poetry build -vvv
2828

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

3333
# Run pylint+mypy after installing psutil so they don't complain on missing dependencies

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Monitor Python web apps using
88
[Spring Boot Admin](https://github.com/codecentric/spring-boot-admin).
99

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

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

examples/Advanced/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ python = "^3.7"
1111
psutil = { version = "^5.6" }
1212
fastapi = { version = "^0.41.0" }
1313
uvicorn = { version = "^0.9.0" }
14-
pyctuator = { version = "^0.13" }
14+
pyctuator = { version = "^0.13.1" }
1515
sqlalchemy = { version = "^1.3" }
1616
PyMySQL = { version = "^0.9.3" }
1717
cryptography = { version = "^2.8" }

examples/FastAPI/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ python = "^3.7"
1111
psutil = { version = "^5.6" }
1212
fastapi = { version = "^0.41.0" }
1313
uvicorn = { version = "^0.9.0" }
14-
pyctuator = { version = "^0.13" }
14+
pyctuator = { version = "^0.13.1" }
1515

1616
[build-system]
1717
requires = ["poetry>=0.12"]

examples/Flask/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors = [
1010
python = "^3.7"
1111
psutil = { version = "^5.6" }
1212
flask = { version = "^1.1" }
13-
pyctuator = { version = "^0.13" }
13+
pyctuator = { version = "^0.13.1" }
1414

1515
[build-system]
1616
requires = ["poetry>=0.12"]

examples/aiohttp/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors = [
1010
python = "^3.7"
1111
psutil = { version = "^5.6" }
1212
aiohttp = { version = "^3.5.4" }
13-
pyctuator = { version = "^0.13" }
13+
pyctuator = { version = "^0.13.1" }
1414

1515
[build-system]
1616
requires = ["poetry>=0.12"]

examples/images/tornado.png

55.3 KB
Loading

examples/tornado/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Tornado example
2+
This example demonstrates the integration with the [Tornado](https://www.tornadoweb.org/).
3+
4+
## Running the example
5+
1. Start an instance of SBA (Spring Boot Admin):
6+
```sh
7+
docker run --rm -p 8080:8080 michayaak/spring-boot-admin:2.2.3-1
8+
```
9+
2. Once Spring Boot Admin is running, you can run the examples as follow:
10+
```sh
11+
cd examples/tornado
12+
poetry install
13+
poetry run python -m tornado_example_app
14+
```
15+
16+
![tornado Example](../images/tornado.png)
17+

examples/tornado/pyproject.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[tool.poetry]
2+
name = "tornado-pyctuator-example"
3+
version = "1.0.0"
4+
description = "Example of using Pyctuator"
5+
authors = [
6+
"Desmond Stonie <[email protected]>",
7+
]
8+
9+
[tool.poetry.dependencies]
10+
python = "^3.7"
11+
psutil = { version = "^5.6" }
12+
tornado = { version = "^6.0.4" }
13+
pyctuator = { version = "^0.13.1" }
14+
15+
[build-system]
16+
requires = ["poetry>=0.12"]
17+
build-backend = "poetry.masonry.api"
18+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import datetime
2+
import logging
3+
import random
4+
5+
from tornado import ioloop
6+
from tornado.httpserver import HTTPServer
7+
from tornado.web import Application, RequestHandler
8+
9+
from pyctuator.pyctuator import Pyctuator
10+
11+
my_logger = logging.getLogger("example")
12+
13+
14+
class HomeHandler(RequestHandler):
15+
def get(self):
16+
my_logger.debug(f"{datetime.datetime.now()} - {str(random.randint(0, 100))}")
17+
self.write("Hello World!")
18+
19+
20+
app = Application(
21+
[
22+
(r"/", HomeHandler)
23+
],
24+
debug=False
25+
)
26+
27+
example_app_address = "host.docker.internal"
28+
example_sba_address = "localhost"
29+
30+
Pyctuator(
31+
app,
32+
"Tornado Pyctuator",
33+
app_url=f"http://{example_app_address}:5000",
34+
pyctuator_endpoint_url=f"http://{example_app_address}:5000/pyctuator",
35+
registration_url=f"http://{example_sba_address}:8080/instances",
36+
app_description="Demonstrate Spring Boot Admin Integration with Tornado",
37+
)
38+
39+
http_server = HTTPServer(app, decompress_request=True)
40+
http_server.listen(5000)
41+
ioloop.IOLoop.current().start()

0 commit comments

Comments
 (0)