OpenClawDashboard/bridge/src/routes/restart.ts
Mannu d4a3f2b869 feat: complete Tiger dashboard implementation
- Bridge: Express API server with SQLite (projects, tasks, executions, outputs)
- Dashboard: Next.js app rewired from WebSocket gateway to Tiger Bridge HTTP API
- Tasks: Kanban board with drag-drop, project management with CRUD
- Dispatch: Task dispatch to sandbox with file watcher for status updates
- UI: Container health panel, workspace browser, logs viewer, output viewer

Critical fixes:
- Use execInSandbox instead of execOnHost for container operations
- Watch symlink path instead of container-internal path
- URL-encoded params for GET requests instead of body
- PUT/DELETE support added to useBridgeRequest

Sprints 1-5 complete. Ready for VPS deployment.
2026-04-12 23:27:51 +05:30

59 lines
1.6 KiB
TypeScript

/**
* restart.ts — POST /tiger/restart
*
* Trigger a Tiger container restart via the gateway watchdog script.
*
* Why a watchdog script?
* A simple `docker restart` would work, but the OpenClaw gateway needs
* specific flags (--allow-unconfigured) and the correct sequence to
* come back up cleanly. The watchdog handles all of that.
*
* The watchdog lives at /root/gateway-watchdog.sh on the VPS host.
*
* POST /tiger/restart
* Optional body: { "reason": "string" } — logged but not used operationally
*
* Response:
* { ok: true, message: "..." } — restart was triggered
* { ok: false, error: "..." } — something went wrong
*/
import { Router, Request, Response } from "express";
import { restartTiger } from "../tiger.js";
const router = Router();
router.post("/", async (req: Request, res: Response) => {
// Optional reason — useful for audit logs
const reason = (req.body?.reason as string) || "manual restart via dashboard";
console.log(`[tiger-bridge] Restart requested. Reason: ${reason}`);
try {
const result = await restartTiger();
if (result.success) {
res.json({
ok: true,
message: result.message || "Tiger restart triggered",
reason,
});
} else {
// Watchdog ran but returned non-zero exit code
res.status(500).json({
ok: false,
error: result.message || "Restart failed",
reason,
});
}
} catch (err: any) {
res.status(500).json({
ok: false,
error: "Failed to trigger restart",
details: err.message,
reason,
});
}
});
export default router;