* @returns {Promise }
()
| 60 | * @returns {Promise<void>} |
| 61 | */ |
| 62 | async initAsync() { |
| 63 | await super.initAsync(); |
| 64 | |
| 65 | if (aiConfig.syncOnStartup) { |
| 66 | try { |
| 67 | // Ensure the system is healthy before attempting a sync. |
| 68 | // This call is cached/deduplicated by HealthService, so it's cheap if the server |
| 69 | // has already checked it. |
| 70 | const health = await HealthService.healthcheck(); |
| 71 | |
| 72 | if (health.status === 'healthy') { |
| 73 | logger.info('[SyncService] Starting automatic startup sync...'); |
| 74 | await this.runFullSync(); |
| 75 | } else { |
| 76 | logger.warn('[SyncService] Skipping startup sync: GitHub CLI is unhealthy.'); |
| 77 | } |
| 78 | } catch (error) { |
| 79 | // We strictly catch errors here to ensure that a sync failure (network, API, etc.) |
| 80 | // does not crash the entire service or prevent the server from starting. |
| 81 | logger.error('[SyncService] Startup sync failed:', error.message); |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * The main public entry point for the synchronization process. |
nothing calls this directly
no test coverage detected