| 86 | } |
| 87 | |
| 88 | constructor(file: string, autoDestroy: boolean) { |
| 89 | this.forkFile = file |
| 90 | this.autoDestroy = autoDestroy |
| 91 | this.callback = {} |
| 92 | |
| 93 | this.onMessage = this.onMessage.bind(this) |
| 94 | this.onError = this.onError.bind(this) |
| 95 | this.onExit = this.onExit.bind(this) |
| 96 | this.onSpawn = this.onSpawn.bind(this) |
| 97 | |
| 98 | this.loading = true |
| 99 | const child = utilityProcess.fork(file) |
| 100 | child.postMessage({ Server: JSON.parse(JSON.stringify(Server)) }) |
| 101 | child.on('message', this.onMessage) |
| 102 | child.on('error', this.onError) |
| 103 | child.on('exit', this.onExit) |
| 104 | child.on('spawn', this.onSpawn) |
| 105 | this.child = child |
| 106 | } |
| 107 | |
| 108 | isChildDisabled() { |
| 109 | if (this.loading) { |