fix port issue

This commit is contained in:
Dax Raad
2025-06-03 16:35:37 -04:00
parent 37c34fd39c
commit 1e063e7937
3 changed files with 6 additions and 3 deletions

View File

@@ -43,6 +43,10 @@ cli.command("", "Start the opencode in interactive mode").action(async () => {
stdout: "inherit", stdout: "inherit",
stderr: "inherit", stderr: "inherit",
stdin: "inherit", stdin: "inherit",
env: {
...process.env,
OPENCODE_SERVER: server.url.toString(),
},
onExit: () => { onExit: () => {
server.stop() server.stop()
}, },

View File

@@ -13,7 +13,6 @@ import { Global } from "../global"
export namespace Server { export namespace Server {
const log = Log.create({ service: "server" }) const log = Log.create({ service: "server" })
const PORT = 16713
export type Routes = ReturnType<typeof app> export type Routes = ReturnType<typeof app>
@@ -401,7 +400,7 @@ export namespace Server {
export function listen() { export function listen() {
const server = Bun.serve({ const server = Bun.serve({
port: PORT, port: 0,
hostname: "0.0.0.0", hostname: "0.0.0.0",
idleTimeout: 0, idleTimeout: 0,
fetch: app().fetch, fetch: app().fetch,

View File

@@ -17,7 +17,7 @@ import (
) )
func main() { func main() {
url := "http://localhost:16713" url := os.Getenv("OPENCODE_SERVER")
httpClient, err := client.NewClientWithResponses(url) httpClient, err := client.NewClientWithResponses(url)
if err != nil { if err != nil {
slog.Error("Failed to create client", "error", err) slog.Error("Failed to create client", "error", err)