Skip to content

Commit

Permalink
Deactivate admin api (#133)
Browse files Browse the repository at this point in the history
Stop the threads for:
Scheduled workflows
Queues
Kafka
  • Loading branch information
manojdbos authored Oct 22, 2024
1 parent 34f1b78 commit 24577f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dbos/admin_sever.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
health_check_path = "/dbos-healthz"
workflow_recovery_path = "/dbos-workflow-recovery"
perf_path = "/dbos-perf"
deactivate_path = "/deactivate"


class AdminServer:
Expand Down Expand Up @@ -66,6 +67,15 @@ def do_GET(self) -> None:
self.send_response(200)
self._end_headers()
self.wfile.write(json.dumps(perf_util).encode("utf-8"))
elif self.path == deactivate_path:
dbos_logger.info("Deactivating DBOS")
# Stop all scheduled workflows, queues, and kafka loops
for event in self.dbos.stop_events:
event.set()

self.send_response(200)
self._end_headers()
self.wfile.write("deactivated".encode("utf-8"))
else:
self.send_response(404)
self._end_headers()
Expand Down
7 changes: 7 additions & 0 deletions tests/test_admin_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ def test_admin_endpoints(dbos: DBOS) -> None:
response = requests.post("http://localhost:3001/stuff", timeout=5)
assert response.status_code == 404

response = requests.get("http://localhost:3001/deactivate", timeout=5)
assert response.status_code == 200

for event in dbos.stop_events:
assert event.is_set(), "Event is not set!"



def test_admin_recovery(dbos: DBOS) -> None:
os.environ["DBOS__VMID"] = "testexecutor"
Expand Down

0 comments on commit 24577f7

Please sign in to comment.