Skip to content

Commit

Permalink
Merge pull request #433 from garden-io/predictable-port
Browse files Browse the repository at this point in the history
Allow explicitly picking port for api in dev cmd
  • Loading branch information
edvald authored Dec 10, 2018
2 parents 39f1c42 + 919e6b8 commit d2a2520
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions garden-service/src/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { LoggerType } from "../logger/logger"
import { IntegerParameter } from "./base"
import { Command, CommandResult, CommandParams } from "./base"
import { sleep } from "../util/util"
import { startServer } from "../server/server"
import { startServer, DEFAULT_PORT } from "../server/server"

const serveArgs = {}

const serveOpts = {
port: new IntegerParameter({
help: `The port number for the Garden service to listen on.`,
defaultValue: 9777,
defaultValue: DEFAULT_PORT,
}),
}

Expand Down
4 changes: 3 additions & 1 deletion garden-service/src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ export async function processModules(

// Experimental HTTP API and dashboard server.
if (process.env.GARDEN_ENABLE_SERVER === "1") {
await startServer(garden, log)
// allow overriding automatic port picking
const port = Number(process.env.GARDEN_SERVER_PORT) || undefined
await startServer(garden, log, port)
}

await restartPromise
Expand Down
2 changes: 2 additions & 0 deletions garden-service/src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const DASHBOARD_BUILD_PATH = resolve(
isPkg ? process.execPath : __dirname, "..", "..", "..", "garden-dashboard", "build",
)

export const DEFAULT_PORT = 9777

/**
* Start an HTTP server that exposes commands and events for the given Garden instance.
*
Expand Down

0 comments on commit d2a2520

Please sign in to comment.