diff --git a/src/server/api/sync.ts b/src/server/api/sync.ts index 2689503..2d99a44 100644 --- a/src/server/api/sync.ts +++ b/src/server/api/sync.ts @@ -1,4 +1,4 @@ -import { APPS_DIR, allApps, registerApp, removeApp, restartApp } from '$apps' +import { APPS_DIR, allApps, registerApp, removeApp, restartApp, startApp } from '$apps' import { computeHash, generateManifest } from '../sync' import { loadGitignore } from '@gitignore' import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, symlinkSync, unlinkSync, watch, writeFileSync } from 'fs' @@ -329,6 +329,9 @@ router.post('/apps/:app/activate', async c => { } catch (e) { return c.json({ error: `Failed to restart app: ${e instanceof Error ? e.message : String(e)}` }, 500) } + } else if (app.state === 'stopped' || app.state === 'invalid') { + // App not running (possibly due to error) - try to start it + startApp(appName) } return c.json({ ok: true })