feat(scripts): run script executions in background and poll for completion

Community scripts (build.func) install packages like Java/OpenSearch and
can take minutes, well past the nginx/proxy HTTP timeout. execute_script
now returns immediately with status "running" and finishes the job on a
background thread with its own DB session; the frontend polls
/api/scripts/executions/{id} every 3s while running.

Also set TERM=xterm for script execution over SSH — community scripts
call `clear` and print colored output, which fails with "TERM
environment variable not set" when run without a PTY.
This commit is contained in:
markmorado
2026-07-23 21:59:18 +05:00
parent 761bd7bca8
commit 0b0b11c689
4 changed files with 86 additions and 19 deletions

View File

@@ -146,5 +146,7 @@ export function useScriptExecution(id: number) {
queryKey: scriptKeys.execution(id),
queryFn: () => apiClient.get<ScriptExecution>(`/api/scripts/executions/${id}`),
enabled: id > 0,
// Выполнение фоновое: пока статус `running`, поллим каждые 3с до завершения.
refetchInterval: (query) => (query.state.data?.status === 'running' ? 3000 : false),
});
}