Files
Hermes-ui/packages/server/src/services/hermes/gateway-runner.ts
T

23 lines
591 B
TypeScript
Raw Normal View History

import { spawn } from 'child_process'
import { getActiveProfileDir } from './hermes-profile'
export function startGatewayRunManaged(
hermesBin: string,
opts: { profileDir?: string } = {},
): { pid: number | null; reused: boolean } {
const profileDir = opts.profileDir || getActiveProfileDir()
const child = spawn(hermesBin, ['gateway', 'run', '--replace'], {
detached: true,
stdio: 'ignore',
windowsHide: true,
env: {
...process.env,
HERMES_HOME: profileDir,
},
})
child.unref()
const pid = child.pid ?? null
return { pid, reused: false }
}