Skip to content

Commit 505320f

Browse files
ntindlemajdyz
andauthored
feat(backend): Move Scheduler (#9904)
<!-- Clearly explain the need for these changes: --> We want the scheduler shouldn't scale with the rest API lol ### Changes 🏗️ pulls out the scheduler into its own service <!-- Concisely describe all of the changes made in this pull request: --> ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [x] test it --------- Co-authored-by: Zamil Majdy <[email protected]>
1 parent 6f15782 commit 505320f

File tree

6 files changed

+85
-10
lines changed

6 files changed

+85
-10
lines changed

autogpt_platform/backend/backend/rest.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from backend.app import run_processes
2-
from backend.executor import DatabaseManager, Scheduler
2+
from backend.executor import DatabaseManager
33
from backend.notifications.notifications import NotificationManager
44
from backend.server.rest_api import AgentServer
55

@@ -11,7 +11,6 @@ def main():
1111
run_processes(
1212
NotificationManager(),
1313
DatabaseManager(),
14-
Scheduler(),
1514
AgentServer(),
1615
)
1716

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from backend.app import run_processes
2+
from backend.executor.scheduler import Scheduler
3+
4+
5+
def main():
6+
"""
7+
Run all the processes required for the AutoGPT-server Scheduling System.
8+
"""
9+
run_processes(Scheduler())
10+
11+
12+
if __name__ == "__main__":
13+
main()

autogpt_platform/backend/pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ build-backend = "poetry.core.masonry.api"
8888
app = "backend.app:main"
8989
rest = "backend.rest:main"
9090
ws = "backend.ws:main"
91+
scheduler = "backend.scheduler:main"
9192
executor = "backend.exec:main"
9293
cli = "backend.cli:main"
9394
format = "linter:format"

autogpt_platform/docker-compose.platform.yml

+58-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ services:
7373
condition: service_completed_successfully
7474
rabbitmq:
7575
condition: service_healthy
76+
# scheduler_server:
77+
# condition: service_healthy
7678
environment:
7779
- SUPABASE_URL=http://kong:8000
7880
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
@@ -88,7 +90,7 @@ services:
8890
- REDIS_PASSWORD=password
8991
- ENABLE_AUTH=true
9092
- PYRO_HOST=0.0.0.0
91-
- EXECUTIONSCHEDULER_HOST=rest_server
93+
- SCHEDULER_HOST=scheduler_server
9294
- EXECUTIONMANAGER_HOST=executor
9395
- NOTIFICATIONMANAGER_HOST=rest_server
9496
- FRONTEND_BASE_URL=http://localhost:3000
@@ -98,7 +100,6 @@ services:
98100
ports:
99101
- "8006:8006"
100102
- "8007:8007"
101-
- "8003:8003" # execution scheduler
102103
networks:
103104
- app-network
104105

@@ -187,6 +188,61 @@ services:
187188
networks:
188189
- app-network
189190

191+
scheduler_server:
192+
build:
193+
context: ../
194+
dockerfile: autogpt_platform/backend/Dockerfile
195+
target: server
196+
command: ["python", "-m", "backend.scheduler"]
197+
develop:
198+
watch:
199+
- path: ./
200+
target: autogpt_platform/backend/
201+
action: rebuild
202+
depends_on:
203+
db:
204+
condition: service_healthy
205+
redis:
206+
condition: service_healthy
207+
rabbitmq:
208+
condition: service_healthy
209+
migrate:
210+
condition: service_completed_successfully
211+
# healthcheck:
212+
# test:
213+
# [
214+
# "CMD",
215+
# "curl",
216+
# "-f",
217+
# "-X",
218+
# "POST",
219+
# "http://localhost:8003/health_check",
220+
# ]
221+
# interval: 10s
222+
# timeout: 10s
223+
# retries: 5
224+
environment:
225+
- DATABASEMANAGER_HOST=rest_server
226+
- NOTIFICATIONMANAGER_HOST=rest_server
227+
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
228+
- DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
229+
- DIRECT_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
230+
- REDIS_HOST=redis
231+
- REDIS_PORT=6379
232+
- REDIS_PASSWORD=password
233+
- RABBITMQ_HOST=rabbitmq
234+
- RABBITMQ_PORT=5672
235+
- RABBITMQ_DEFAULT_USER=rabbitmq_user_default
236+
- RABBITMQ_DEFAULT_PASS=k0VMxyIJF9S35f3x2uaw5IWAl6Y536O7
237+
- ENABLE_AUTH=true
238+
- PYRO_HOST=0.0.0.0
239+
- BACKEND_CORS_ALLOW_ORIGINS=["http://localhost:3000"]
240+
241+
ports:
242+
- "8003:8003"
243+
networks:
244+
- app-network
245+
190246
# frontend:
191247
# build:
192248
# context: ../

autogpt_platform/docker-compose.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,17 @@ services:
5757
file: ./docker-compose.platform.yml
5858
service: websocket_server
5959

60-
# frontend:
61-
# <<: *agpt-services
62-
# extends:
63-
# file: ./docker-compose.platform.yml
64-
# service: frontend
60+
scheduler_server:
61+
<<: *agpt-services
62+
extends:
63+
file: ./docker-compose.platform.yml
64+
service: scheduler_server
65+
66+
# frontend:
67+
# <<: *agpt-services
68+
# extends:
69+
# file: ./docker-compose.platform.yml
70+
# service: frontend
6571

6672
# Supabase services
6773
studio:

docs/content/platform/getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ Currently, there are only 3 active services:
382382

383383
- AgentServer (the API, defined in `server.py`)
384384
- ExecutionManager (the executor, defined in `manager.py`)
385-
- ExecutionScheduler (the scheduler, defined in `scheduler.py`)
385+
- Scheduler (the scheduler, defined in `scheduler.py`)
386386

387387
The services run in independent Python processes and communicate through an IPC.
388388
A communication layer (`service.py`) is created to decouple the communication library from the implementation.

0 commit comments

Comments
 (0)