()
| 159 | } |
| 160 | |
| 161 | restartHttpServer() { |
| 162 | if (this.serverRestartPromise) { |
| 163 | return this.serverRestartPromise.then(() => this.restartHttpServer()); |
| 164 | } |
| 165 | |
| 166 | this.serverRestartPromise = (async () => { |
| 167 | try { |
| 168 | await this.stopHttpServer(); |
| 169 | this.invalidateCache(this.serverRoot); |
| 170 | await this.startHttpServer(); |
| 171 | |
| 172 | this.emit('restart'); |
| 173 | this.ui.writeLine(''); |
| 174 | this.ui.writeLine(chalk.green('Server restarted.')); |
| 175 | this.ui.writeLine(''); |
| 176 | } catch (err) { |
| 177 | this.ui.writeError(err); |
| 178 | } finally { |
| 179 | this.serverRestartPromise = null; |
| 180 | } |
| 181 | })(); |
| 182 | |
| 183 | return this.serverRestartPromise; |
| 184 | } |
| 185 | |
| 186 | stopHttpServer() { |
| 187 | return new Promise((resolve, reject) => { |
no test coverage detected