Commit 90276ce
authored
feat: add automatic worker restart via cron job and worker health tracking (#517)
# Add automatic worker restart system for edge functions
This PR implements a comprehensive worker management system that automatically restarts edge functions when they stop running. Key features include:
- Added `ensure_workers()` cron job that monitors and restarts edge functions
- Created `worker_functions` table to track registered edge functions and their health status
- Added `stopped_at` column to workers table for detecting graceful shutdowns
- Integrated `trackWorkerFunction` and `markWorkerStopped` functions into edge worker lifecycle
- Consolidated temporary migrations into a single migration file
- Removed manual `drop function` statements from SQL schema files
- Removed redundant test setup code as worker restart is now automatic
The system works by having edge functions register themselves on startup, then monitoring their health via heartbeats. When a worker stops (either gracefully or by crashing), the cron job automatically restarts it. This improves reliability by ensuring workers stay running without manual intervention.1 parent e4cd7bb commit 90276ce
File tree
20 files changed
+270
-302
lines changed- .changeset
- pkgs
- core
- schemas
- supabase/migrations
- edge-worker/tests/e2e
20 files changed
+270
-302
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | 5 | | |
8 | 6 | | |
9 | 7 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | 5 | | |
8 | 6 | | |
9 | 7 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
| |||
Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 0 additions & 12 deletions
This file was deleted.
0 commit comments