mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-10 04:58:28 +00:00
fix(cli): increment ports from default (#33282)
This commit is contained in:
parent
4ecc3ac653
commit
57ce1b9ca8
1 changed files with 5 additions and 3 deletions
|
|
@ -27,9 +27,11 @@ export default Runtime.handler(
|
|||
|
||||
function listen(hostname: string, port: Option.Option<number>, password: string) {
|
||||
if (Option.isSome(port)) return bind(hostname, port.value, password)
|
||||
// Preserve the familiar default when available, but let the OS choose a free
|
||||
// port when another local server already owns 4096.
|
||||
return bind(hostname, 4096, password).pipe(Effect.catch(() => bind(hostname, 0, password)))
|
||||
const next = (port: number): ReturnType<typeof bind> =>
|
||||
bind(hostname, port, password).pipe(
|
||||
Effect.catch((error) => (port === 65_535 ? Effect.fail(error) : next(port + 1))),
|
||||
)
|
||||
return next(4096)
|
||||
}
|
||||
|
||||
function bind(hostname: string, port: number, password: string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue