Skip to content

Commit f572dee

Browse files
authored
Add --wait-for-services-timeout option to CLI (#1796)
1 parent fbe080d commit f572dee

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/argv.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ export class Argv {
350350
return this.map.get("waitImage") ?? "docker.io/sumina46/wait-for-it:latest";
351351
}
352352

353+
get waitForServicesTimeout (): number {
354+
return this.map.get("waitForServicesTimeout") ?? 30;
355+
}
356+
353357
get helperImage (): string {
354358
return this.map.get("helperImage") ?? "docker.io/firecow/gitlab-ci-local-util:latest";
355359
}

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ process.on("SIGUSR2", async () => {
207207
description: "Which image to be used for the wait container. Defaults to docker.io/sumina46/wait-for-it:latest if not set.",
208208
requiresArg: false,
209209
})
210+
.option("wait-for-services-timeout", {
211+
type: "number",
212+
description: "Timeout in seconds for service health checks. Defaults to 30.",
213+
requiresArg: false,
214+
})
210215
.option("helper-image", {
211216
type: "string",
212217
description: "When using --shell-executor-no-image=false which image to be used for the utils container. Defaults to docker.io/firecow/gitlab-ci-local-util:latest if not set.",

src/job.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,7 @@ If you know what you're doing and would like to suppress this warning, use one o
16451645
const serviceAlias = service.alias;
16461646
const serviceName = service.name;
16471647
const waitImageName = this.argv.waitImage;
1648+
const waitForServicesTimeout = this.argv.waitForServicesTimeout;
16481649

16491650
const {stdout} = await Utils.spawn([this.argv.containerExecutable, "image", "inspect", serviceName]);
16501651
const imageInspect = JSON.parse(stdout);
@@ -1669,7 +1670,7 @@ If you know what you're doing and would like to suppress this warning, use one o
16691670
if (!port.endsWith("/tcp")) return;
16701671
const portNum = parseInt(port.replace("/tcp", ""));
16711672
const containerName = `gcl-wait-for-it-${this.jobId}-${serviceIndex}-${portNum}`;
1672-
const spawnCmd = [this.argv.containerExecutable, "run", "--rm", `--name=${containerName}`, "--network", `${this._serviceNetworkId}`, `${waitImageName}`, `${uniqueAlias}:${portNum}`, "-t", "30"];
1673+
const spawnCmd = [this.argv.containerExecutable, "run", "--rm", `--name=${containerName}`, "--network", `${this._serviceNetworkId}`, `${waitImageName}`, `${uniqueAlias}:${portNum}`, "-t", `${waitForServicesTimeout}`];
16731674
this._containersToClean.push(containerName);
16741675
return Utils.spawn(spawnCmd);
16751676
}));

0 commit comments

Comments
 (0)