Skip to content

Commit b712422

Browse files
authored
Merge pull request #133 from GabrielSalla/convert-to-scripts
Convert to scripts
2 parents d2908c4 + f41c371 commit b712422

14 files changed

+65
-42
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def search():
4040
# {
4141
# "order_id": 123,
4242
# "order_status": "awaiting_delivery",
43-
# "shipment_status": "completed",
4443
# },
4544
# ...
4645
# ]
@@ -59,19 +58,17 @@ def search():
5958
return issues
6059

6160
def update(issues):
62-
# Refreshes order and shipment statuses for the provided order IDs
61+
# Refreshes order status for the provided order IDs
6362
#
6463
# Example SQL:
6564
# select
6665
# orders.id as order_id,
6766
# orders.status as order_status
6867
# from orders
69-
# left join shipments
70-
# on shipments.order_id = orders.id
7168
# where
7269
# orders.id in (<list_of_order_ids>);
7370
order_ids = [issue["order_id"] for issue in issues]
74-
updated_issues = get_orders_and_shipments_status(order_ids)
71+
updated_issues = get_orders_status(order_ids)
7572
return updated_issues
7673

7774
def is_solved(issue):

docker/docker-compose-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ services:
4545
depends_on:
4646
- postgres
4747
- motoserver
48-
command: python3 src/main.py controller executor
48+
command: sentinela controller executor

docker/docker-compose-local.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ services:
1717
ports:
1818
- 8000:8000
1919
healthcheck:
20-
test: python tools/health_check.py 8000
20+
test: health_check 8000
2121
interval: 10s
2222
timeout: 1s
2323
retries: 3
@@ -33,4 +33,4 @@ services:
3333
- .env.secrets
3434
depends_on:
3535
- postgres
36-
command: python3 src/main.py controller executor
36+
command: sentinela controller executor

docker/docker-compose-scalable.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ services:
2828
ports:
2929
- 8000:8000
3030
healthcheck:
31-
test: python tools/health_check.py 8000
31+
test: health_check 8000
3232
interval: 10s
3333
timeout: 1s
3434
retries: 3
@@ -45,7 +45,7 @@ services:
4545
depends_on:
4646
- postgres
4747
- motoserver
48-
command: python3 src/main.py controller
48+
command: sentinela controller
4949

5050
sentinela-executor:
5151
build:
@@ -61,7 +61,7 @@ services:
6161
ports:
6262
- 8001-8100:8000
6363
healthcheck:
64-
test: python tools/health_check.py 8000
64+
test: health_check 8000
6565
interval: 10s
6666
timeout: 1s
6767
retries: 3
@@ -78,4 +78,4 @@ services:
7878
depends_on:
7979
- postgres
8080
- motoserver
81-
command: python3 src/main.py executor
81+
command: sentinela executor

docs/how_to_run.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ For testing purposes, it can be useful to start a container and execute multiple
1818
```shell
1919
make run-shell-dev
2020
```
21+
2. When inside the container, the application can be run in development mode.
22+
```shell
23+
sentinela controller executor
24+
```
25+
or omitting the parameters to run both the controller and executor.
2126

22-
The quality checks can also be run.
27+
The quality checks can also be run using the following commands:
2328
1. Run the tests.
2429
```shell
2530
make test-dev
@@ -106,7 +111,7 @@ The [Dockerfile](../Dockerfile) is a starting point for building the application
106111

107112
1. Install the dependencies for the application and enabled plugins.
108113
```shell
109-
poetry install --no-root --only $(python ./tools/get_plugins_list.py)
114+
poetry install --no-root --only $(get_plugins_list)
110115
```
111116

112117
### Deploying the Application
@@ -119,9 +124,9 @@ All services must have the environment variables set as specified in the [Config
119124
Controllers and executors can be run by specifying them as parameters when starting the application:
120125
1. Run the controller.
121126
```shell
122-
python3 src/main.py controller
127+
sentinela controller
123128
```
124129
2. Run the executor.
125130
```shell
126-
python3 src/main.py executor
131+
sentinela executor
127132
```

docs/monitor_registering.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To simplify the registration process, a Python script is available in the `tools
5858
The following example demonstrates how to use the script to register a new monitor:
5959

6060
```bash
61-
python tools/register_monitor.py \
61+
register_monitor \
6262
my_monitor \
6363
monitors/my_monitor/my_monitor.py \
6464
monitors/my_monitor/search_query.sql \

pyproject.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@ name = "Sentinela"
33
version = "0.7.0"
44
description = "Sentinela Monitoring Platform"
55
authors = [
6-
{ name = "Gabriel Salla", email = "gabriel.c.salla@gmail.com" }
6+
{ name = "Gabriel Salla", email = "gabriel.c.salla@gmail.com" },
77
]
88
license = { file = "LICENSE.txt" }
99
readme = "README.md"
1010

1111
[tool.poetry]
12-
package-mode = false
12+
name = "sentinela"
13+
packages = [
14+
{include = "*", from = "src"},
15+
{include = "tools"},
16+
]
17+
18+
[tool.poetry.scripts]
19+
sentinela = "main:start"
20+
get_plugins_list = "tools.get_plugins_list:main"
21+
health_check = "tools.health_check:main"
22+
register_monitor = "tools.register_monitor:main"
1323

1424
[tool.poetry.dependencies]
1525
python = "^3.12"
@@ -96,9 +106,9 @@ log_format = "%(asctime)s [%(levelname)s] %(name)s.%(funcName)s.%(lineno)d: %(me
96106

97107
# Disable botocore 'datetime.datetime.utcnow()' deprecation warning
98108
filterwarnings = [
99-
"error",
100109
"ignore:datetime.datetime.utcnow:DeprecationWarning:botocore",
101110
]
111+
102112
[tool.coverage.run]
103113
branch = true
104114

resources/kubernetes_template/controller.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
- name: sentinela-controller
1919
image: sentinela-local:latest
2020
imagePullPolicy: Never
21-
command: ["python3", "src/main.py", "controller"]
21+
command: ["sentinela", "controller"]
2222
ports:
2323
- containerPort: 8000
2424
env:

resources/kubernetes_template/executor.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
- name: sentinela-executor
1919
image: sentinela-local:latest
2020
imagePullPolicy: Never
21-
command: ["python3", "src/main.py", "executor"]
21+
command: ["sentinela", "executor"]
2222
ports:
2323
- containerPort: 8000
2424
env:

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@ async def main() -> None:
9696
)
9797

9898

99-
if __name__ == "__main__":
99+
def start() -> None:
100100
asyncio.run(main())

0 commit comments

Comments
 (0)