Skip to content

Commit

Permalink
refactor(options): improve timeout params (#37)
Browse files Browse the repository at this point in the history
Signed-off-by: Black-Hole1 <[email protected]>
  • Loading branch information
BlackHole1 authored Dec 13, 2023
1 parent e1fcb05 commit 1a11700
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/darwin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,11 @@ export class DarwinOVM {

private initReady(): void {
this.ready = new Promise((resolve, reject) => {
const timeout = this.options.timeout?.ready ?? 1000 * 30;
const id = setTimeout(() => {
server.close();
reject(new Error("ready timeout"));
}, 1000 * 30);
}, timeout);

const server = net.createServer((conn) => {
conn.on("data", () => {
Expand Down Expand Up @@ -367,7 +368,7 @@ export class DarwinOVM {
const cmd = [mount, authorizedKeys, ready, tz].join(";");

return new Promise((resolve, reject) => {
const timeout = this.options.timeout ?? 1000 * 20;
const timeout = this.options.timeout?.ignition ?? 1000 * 10;
const id = setTimeout(() => {
server.close();
reject(new Error("ignition timeout"));
Expand Down
5 changes: 4 additions & 1 deletion src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export interface OVMDarwinOptions {
logDir: string;
sshKeyDir: string;
versions: OVMDarwinOptions["originPath"]
timeout?: number;
timeout?: {
ready?: number;
ignition?: number;
}
}

export interface OVMEventData {
Expand Down

0 comments on commit 1a11700

Please sign in to comment.