()
| 143 | * Main entry point: auto-start hub if conditions are met |
| 144 | */ |
| 145 | export async function maybeAutoStartServer(): Promise<void> { |
| 146 | try { |
| 147 | const shouldStart = await shouldAutoStartServer() |
| 148 | if (!shouldStart) { |
| 149 | return |
| 150 | } |
| 151 | |
| 152 | logger.debug('[AUTO-START] Starting hub automatically...') |
| 153 | console.log(chalk.gray('Starting HAPI hub in background...')) |
| 154 | |
| 155 | startServerAsChild() |
| 156 | |
| 157 | const isReady = await waitForServerReady(configuration.apiUrl) |
| 158 | |
| 159 | if (!isReady) { |
| 160 | console.log(chalk.yellow('Warning: Hub did not start within expected time')) |
| 161 | console.log(chalk.gray(' Try running `hapi hub` manually to see errors')) |
| 162 | return |
| 163 | } |
| 164 | |
| 165 | console.log(chalk.green('HAPI hub started')) |
| 166 | } catch (error) { |
| 167 | logger.debug('[AUTO-START] Error during hub auto-start', error) |
| 168 | console.log(chalk.yellow('Warning: Failed to auto-start hub')) |
| 169 | if (error instanceof Error) { |
| 170 | console.log(chalk.gray(` Error: ${error.message}`)) |
| 171 | } |
| 172 | } |
| 173 | } |
no test coverage detected