@@ -6,6 +6,7 @@ Standalone admin panel with all data stored in SQLite database
6
6
- [ Broker-agnostic admin panel for Taskiq] ( #broker-agnostic-admin-panel-for-taskiq )
7
7
- [ Previews] ( #previews )
8
8
- [ Usage] ( #usage )
9
+ - [ Docker Compose Examples] ( #docker-compose-examples )
9
10
- [ Development] ( #development )
10
11
11
12
### Previews
@@ -19,13 +20,14 @@ Tasks Page | Task Details Page
19
20
20
21
``` python
21
22
from typing import Any
23
+ from urllib.parse import urljoin
22
24
from datetime import datetime, UTC
23
25
24
26
import httpx
25
27
from taskiq import TaskiqMiddleware, TaskiqResult, TaskiqMessage
26
28
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
29
31
30
32
31
33
class TaskiqAdminMiddleware (TaskiqMiddleware ):
@@ -35,7 +37,7 @@ class TaskiqAdminMiddleware(TaskiqMiddleware):
35
37
async with httpx.AsyncClient() as client:
36
38
await client.post(
37
39
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" ) ,
39
41
json = {
40
42
" worker" : " WIP" ,
41
43
" args" : message.args,
@@ -59,7 +61,7 @@ class TaskiqAdminMiddleware(TaskiqMiddleware):
59
61
async with httpx.AsyncClient() as client:
60
62
await client.post(
61
63
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" ) ,
63
65
json = {
64
66
" error" : result.error
65
67
if result.error is None
@@ -78,7 +80,7 @@ class TaskiqAdminMiddleware(TaskiqMiddleware):
78
80
79
81
2 ) Pull the image from DockerHub: ` docker pull artur10/taskiq-admin:latest `
80
82
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:
82
84
``` bash
83
85
docker run -d --rm \
84
86
-p " 3000:3000" \
@@ -90,6 +92,43 @@ docker run -d --rm \
90
92
91
93
4 ) Go to ` http://localhost:3000/tasks `
92
94
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
+
93
132
### Development
94
133
1 ) Run ` pnpm install ` to install all dependencies
95
134
2 ) Run ` pnpm db:push ` to create the sqlite database if needed
0 commit comments