From b1cbb90fc2589d9a9ff2a5cb5d1480955065d522 Mon Sep 17 00:00:00 2001 From: Paulo Truta Date: Thu, 26 Nov 2026 13:13:14 +0100 Subject: [PATCH] Never block the task loop on scheduled WS bring-up; sqlite busy timeout taskStartWs() (a full './ws -b': render + docker compose up --build) ran synchronously inside the tick-1 schedule, before GetNextTask() could run. When the VM's docker daemon is slow or wedged, edgeboxctl stays blocked for hours or days and dashboard tasks (e.g. enable_ssh_access) sit in the queue unprocessed. - run the scheduled WS bring-up in a goroutine; the task loop no longer waits for it - add a busy timeout to the shared sqlite connection string so edgeboxctl waits for the API's write locks instead of erroring --- internal/tasks/tasks.go | 9 +++++++-- internal/utils/utils.go | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/tasks/tasks.go b/internal/tasks/tasks.go index 85a4d57..f879b7b 100644 --- a/internal/tasks/tasks.go +++ b/internal/tasks/tasks.go @@ -588,8 +588,13 @@ func ExecuteSchedules(tick int) { uptime := taskGetSystemUptime() log.Println("Uptime is " + uptime + " seconds (" + system.GetUptimeFormatted() + ")") - log.Println(taskGetStorageDevices()) - taskStartWs() + // Run the WS bring-up asynchronously: a full "./ws -b" can take a + // long time (image builds, busy docker daemon) and must never block + // the task loop from fetching queued dashboard tasks. + go func() { + taskStartWs() + log.Println("WS start finished (async)") + }() log.Println(taskGetEdgeApps()) taskUpdateSystemLoggerServices() taskRecoverFromUpdate() diff --git a/internal/utils/utils.go b/internal/utils/utils.go index a2ba471..1e320e5 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -91,7 +91,10 @@ func GetSQLiteDbConnectionDetails() string { log.Fatal("Error loading .env file") } - return apiEnv["SQLITE_DATABASE"] // Will read from api project edgebox.env file + // The API (running in its own container) writes to this same database. + // A busy timeout lets edgeboxctl wait for the lock instead of failing + // instantly when the API is mid-write. + return apiEnv["SQLITE_DATABASE"] + "?_busy_timeout=5000" // Will read from api project edgebox.env file }