Skip to content

Commit

Permalink
feat: allow changing restart timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarpl committed Jul 25, 2022
1 parent 64dac40 commit 73057ac
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/parent-process/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ export class ThreadedClassManagerClass {
return this._internal.handleExit
}

/** How quickly to time out when restarting the threads. Default is 1000ms. */
public set restartTimeout (v: number) {
this._internal.restartTimeout = v
}
public get restartTimeout (): number {
return this._internal.restartTimeout
}

/** Destroy a proxy class */
public destroy (proxy: ThreadedClass<any>): Promise<void> {
return this._internal.killProxy(proxy)
Expand Down Expand Up @@ -158,6 +166,7 @@ export class ThreadedClassManagerClassInternal extends EventEmitter {

/** Set to true if you want to handle the exiting of child process yourselt */
public handleExit = RegisterExitHandlers.AUTO
public restartTimeout = 1000
private isInitialized: boolean = false
private _threadId: number = 0
private _instanceId: number = 0
Expand Down Expand Up @@ -441,9 +450,9 @@ export class ThreadedClassManagerClassInternal extends EventEmitter {
}
this.on('initialized', onInit)
setTimeout(() => {
reject('Timeout when trying to restart')
reject(`Timeout when trying to restart after ${this.restartTimeout}`)
this.removeListener('initialized', onInit)
}, 1000)
}, this.restartTimeout)
})
const promises: Array<Promise<void>> = []

Expand Down

0 comments on commit 73057ac

Please sign in to comment.