| 198 | } |
| 199 | |
| 200 | shuttingDown = true; |
| 201 | |
| 202 | if (restartTimer) { |
| 203 | clearTimeout(restartTimer); |
| 204 | } |
| 205 | if (rescanTimer) { |
| 206 | clearTimeout(rescanTimer); |
| 207 | } |
| 208 | |
| 209 | for (const watcher of watchedDirs.values()) { |
| 210 | watcher.close(); |
| 211 | } |
| 212 | watchedDirs.clear(); |
| 213 | |
| 214 | if (!child) { |
| 215 | process.exit(0); |
| 216 | } |
| 217 | |
| 218 | const childToStop = child; |
| 219 | void stopBackendAndWait(childToStop).then(() => process.exit(0)); |
| 220 | } |
| 221 | |
| 222 | syncWatchers(); |
| 223 | startServer(); |
| 224 | |
| 225 | process.on('SIGINT', () => shutdown('SIGINT')); |
| 226 | process.on('SIGTERM', () => shutdown('SIGTERM')); |