2025-06-25 00:52:09 +00:00
|
|
|
import { Server } from "../../server/server"
|
|
|
|
|
import { cmd } from "./cmd"
|
2025-12-26 20:24:44 +00:00
|
|
|
import { withNetworkOptions, resolveNetworkOptions } from "../network"
|
2026-01-12 20:23:12 +00:00
|
|
|
import { Flag } from "../../flag/flag"
|
2026-02-27 20:36:39 +00:00
|
|
|
import { Workspace } from "../../control-plane/workspace"
|
|
|
|
|
import { Project } from "../../project/project"
|
|
|
|
|
import { Installation } from "../../installation"
|
2025-06-25 00:52:09 +00:00
|
|
|
|
|
|
|
|
export const ServeCommand = cmd({
|
|
|
|
|
command: "serve",
|
2025-12-26 20:24:44 +00:00
|
|
|
builder: (yargs) => withNetworkOptions(yargs),
|
2025-06-25 00:52:09 +00:00
|
|
|
describe: "starts a headless opencode server",
|
|
|
|
|
handler: async (args) => {
|
2026-01-12 20:59:17 +00:00
|
|
|
if (!Flag.OPENCODE_SERVER_PASSWORD) {
|
|
|
|
|
console.log("Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.")
|
2026-01-12 20:23:12 +00:00
|
|
|
}
|
2025-12-26 20:47:44 +00:00
|
|
|
const opts = await resolveNetworkOptions(args)
|
2025-12-26 20:24:44 +00:00
|
|
|
const server = Server.listen(opts)
|
2025-11-03 21:35:46 +00:00
|
|
|
console.log(`opencode server listening on http://${server.hostname}:${server.port}`)
|
2026-02-27 20:36:39 +00:00
|
|
|
|
2025-09-01 21:15:49 +00:00
|
|
|
await new Promise(() => {})
|
2025-10-31 04:57:58 +00:00
|
|
|
await server.stop()
|
2025-06-25 00:52:09 +00:00
|
|
|
},
|
|
|
|
|
})
|