()
| 133 | } |
| 134 | } |
| 135 | |
| 136 | function startServer() { |
| 137 | if (shuttingDown) { |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | const childProcess = spawn(process.execPath, ['--import', 'tsx', entryFile], { |
| 142 | cwd: packageRoot, |
| 143 | stdio: ['inherit', 'inherit', 'inherit', 'ipc'], |
| 144 | env: process.env, |
| 145 | }); |
| 146 | |
| 147 | child = childProcess; |
| 148 | |
| 149 | childProcess.on('exit', (code, signal) => { |
| 150 | if (child !== childProcess) { |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | child = null; |
| 155 | |
| 156 | if (shuttingDown) { |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | if (restartAfterExit) { |
| 161 | restartAfterExit = false; |
| 162 | setTimeout(() => { |
| 163 | if (!shuttingDown && !child) { |
| 164 | startServer(); |
| 165 | restartInProgress = false; |
| 166 | } |
| 167 | }, restartDelayMs); |
| 168 | return; |
| 169 | } |
| 170 | |
| 171 | restartInProgress = false; |
| 172 | |
| 173 | if (code && code !== 0) { |
| 174 | log(`server exited with code ${code}. Waiting for changes...`); |
| 175 | } |
| 176 | }); |
| 177 | } |
| 178 | |
| 179 | function restartServer(changedPath) { |
no test coverage detected