(retryCount = 0, maxRetries = 3)
| 17 | console.log("Waiting 5 seconds to run migrations"); |
| 18 | // Function to trigger migrations with retry logic |
| 19 | const triggerMigrations = async (retryCount = 0, maxRetries = 3) => { |
| 20 | try { |
| 21 | await runMigrations(); |
| 22 | } catch (error) { |
| 23 | console.error( |
| 24 | `🚨 Error triggering migrations (attempt ${retryCount + 1}):`, |
| 25 | error, |
| 26 | ); |
| 27 | if (retryCount < maxRetries - 1) { |
| 28 | console.log( |
| 29 | `🔄 Retrying in 5 seconds... (${retryCount + 1}/${maxRetries})`, |
| 30 | ); |
| 31 | setTimeout(() => triggerMigrations(retryCount + 1, maxRetries), 5000); |
| 32 | } else { |
| 33 | console.error(`🚨 All ${maxRetries} migration attempts failed.`); |
| 34 | process.exit(1); // Exit with error code if all attempts fail |
| 35 | } |
| 36 | } |
| 37 | }; |
| 38 | // Add a timeout to trigger migrations after 5 seconds on server start |
| 39 | setTimeout(() => triggerMigrations(), 5000); |
| 40 | setTimeout(() => createS3Bucket(), 5000); |
no test coverage detected