mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix: move PID lock to bootstrap.ts for all entrypoints
This commit is contained in:
@@ -59,6 +59,7 @@ import type {
|
||||
AgentClient,
|
||||
AgentProvider,
|
||||
} from "./agent/agent-sdk-types.js";
|
||||
import { acquirePidLock, releasePidLock } from "./pid-lock.js";
|
||||
|
||||
type AgentMcpTransportMap = Map<string, StreamableHTTPServerTransport>;
|
||||
|
||||
@@ -498,6 +499,9 @@ export async function createPaseoDaemon(
|
||||
);
|
||||
|
||||
const start = async () => {
|
||||
// Acquire PID lock
|
||||
await acquirePidLock(config.paseoHome, selfIdMcpSocketPath);
|
||||
|
||||
// Start Self-ID MCP socket server first
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const onError = (err: Error) => {
|
||||
@@ -604,6 +608,8 @@ export async function createPaseoDaemon(
|
||||
if (existsSync(selfIdMcpSocketPath)) {
|
||||
unlinkSync(selfIdMcpSocketPath);
|
||||
}
|
||||
// Release PID lock
|
||||
await releasePidLock(config.paseoHome);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { loadConfig } from "./config.js";
|
||||
import { resolvePaseoHome } from "./paseo-home.js";
|
||||
import { createRootLogger } from "./logger.js";
|
||||
import { loadPersistedConfig } from "./persisted-config.js";
|
||||
import { PidLockError } from "./pid-lock.js";
|
||||
|
||||
async function main() {
|
||||
const paseoHome = resolvePaseoHome();
|
||||
@@ -21,7 +22,15 @@ async function main() {
|
||||
}
|
||||
const daemon = await createPaseoDaemon(config, logger);
|
||||
|
||||
await daemon.start();
|
||||
try {
|
||||
await daemon.start();
|
||||
} catch (err) {
|
||||
if (err instanceof PidLockError) {
|
||||
logger.error({ pid: err.existingLock?.pid }, err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
let shuttingDown = false;
|
||||
const handleShutdown = async (signal: string) => {
|
||||
|
||||
Reference in New Issue
Block a user