feat: support OPENCODE_SERVER_PORT and OPENCODE_SERVER_HOSTNAME env vars (#1157)
Add support for customizing the OpenCode server port and hostname via environment variables. This enables orchestration tools like Open Agent to run multiple concurrent missions without port conflicts. Environment variables: - OPENCODE_SERVER_PORT: Custom port for the OpenCode server - OPENCODE_SERVER_HOSTNAME: Custom hostname for the OpenCode server When running oh-my-opencode in parallel (e.g., multiple missions in Open Agent), each instance can now use a unique port to avoid conflicts with the default port 4096.
This commit is contained in:
parent
7f43f160b5
commit
a5d9929c0a
@ -31,8 +31,18 @@ export async function run(options: RunOptions): Promise<number> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Support custom OpenCode server port via environment variable
|
||||||
|
// This allows Open Agent and other orchestrators to run multiple
|
||||||
|
// concurrent missions without port conflicts
|
||||||
|
const serverPort = process.env.OPENCODE_SERVER_PORT
|
||||||
|
? parseInt(process.env.OPENCODE_SERVER_PORT, 10)
|
||||||
|
: undefined
|
||||||
|
const serverHostname = process.env.OPENCODE_SERVER_HOSTNAME || undefined
|
||||||
|
|
||||||
const { client, server } = await createOpencode({
|
const { client, server } = await createOpencode({
|
||||||
signal: abortController.signal,
|
signal: abortController.signal,
|
||||||
|
...(serverPort && !isNaN(serverPort) ? { port: serverPort } : {}),
|
||||||
|
...(serverHostname ? { hostname: serverHostname } : {}),
|
||||||
})
|
})
|
||||||
|
|
||||||
const cleanup = () => {
|
const cleanup = () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user