Skip to content

Commit 0bf8379

Browse files
authored
Merge pull request #19 from spikeninja/dev
feat: update documentation
2 parents e4cfba1 + 0e6e419 commit 0bf8379

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

README.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Standalone admin panel with all data stored in SQLite database
66
- [Broker-agnostic admin panel for Taskiq](#broker-agnostic-admin-panel-for-taskiq)
77
- [Previews](#previews)
88
- [Usage](#usage)
9+
- [Docker Compose Examples](#docker-compose-examples)
910
- [Development](#development)
1011

1112
### Previews
@@ -19,13 +20,14 @@ Tasks Page | Task Details Page
1920

2021
```python
2122
from typing import Any
23+
from urllib.parse import urljoin
2224
from datetime import datetime, UTC
2325

2426
import httpx
2527
from taskiq import TaskiqMiddleware, TaskiqResult, TaskiqMessage
2628

27-
TASKIQ_ADMIN_URL = "..." # or your env vars from .env
28-
TASKIQ_ADMIN_API_TOKEN = "..." # or your env vars from .env
29+
TASKIQ_ADMIN_URL = "..." # or os.getenv() to use .env vars
30+
TASKIQ_ADMIN_API_TOKEN = "..." # or os.getenv() to use .env vars
2931

3032

3133
class TaskiqAdminMiddleware(TaskiqMiddleware):
@@ -35,7 +37,7 @@ class TaskiqAdminMiddleware(TaskiqMiddleware):
3537
async with httpx.AsyncClient() as client:
3638
await client.post(
3739
headers={"access-token": TASKIQ_ADMIN_API_TOKEN},
38-
url=f"{TASKIQ_ADMIN_URL}/tasks/{message.task_id}/started",
40+
url=urljoin(TASKIQ_ADMIN_URL, "/api/tasks/{message.task_id}/started"),
3941
json={
4042
"worker": "WIP",
4143
"args": message.args,
@@ -59,7 +61,7 @@ class TaskiqAdminMiddleware(TaskiqMiddleware):
5961
async with httpx.AsyncClient() as client:
6062
await client.post(
6163
headers={"access-token": TASKIQ_ADMIN_API_TOKEN},
62-
url=f"{TASKIQ_ADMIN_URL}/tasks/{message.task_id}/executed",
64+
url=urljoin(TASKIQ_ADMIN_URL, "/api/tasks/{message.task_id}/executed"),
6365
json={
6466
"error": result.error
6567
if result.error is None
@@ -78,7 +80,7 @@ class TaskiqAdminMiddleware(TaskiqMiddleware):
7880

7981
2) Pull the image from DockerHub: `docker pull artur10/taskiq-admin:latest`
8082

81-
3) Replace `ACCESS_TOKEN` with any secret enough string and run:
83+
3) Replace `TASKIQ_ADMIN_API_TOKEN` with any secret enough string and run:
8284
```bash
8385
docker run -d --rm \
8486
-p "3000:3000" \
@@ -90,6 +92,43 @@ docker run -d --rm \
9092

9193
4) Go to `http://localhost:3000/tasks`
9294

95+
### Docker Compose Examples
96+
97+
.env file example:
98+
```bash
99+
...
100+
TASKIQ_ADMIN_URL=http://taskiq_admin:3000
101+
TASKIQ_ADMIN_API_TOKEN=supersecret
102+
...
103+
```
104+
105+
compose.yml file example
106+
```shell
107+
...
108+
queue:
109+
build:
110+
context: .
111+
dockerfile: ./Dockerfile
112+
container_name: my_queue
113+
command: taskiq worker app.tasks.queue:broker --workers 1 --max-async-tasks 20
114+
env_file:
115+
- .env
116+
depends_on:
117+
- redis
118+
- taskiq_admin
119+
120+
taskiq_admin:
121+
image: artur10/taskiq-admin:latest
122+
container_name: taskiq_admin
123+
ports:
124+
- 3000:3000
125+
env_file:
126+
- .env
127+
volumes:
128+
- ./any/suitable/path:/usr/database/
129+
...
130+
```
131+
93132
### Development
94133
1) Run `pnpm install` to install all dependencies
95134
2) Run `pnpm db:push` to create the sqlite database if needed

0 commit comments

Comments
 (0)