genbox 1.0.81 → 1.0.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/create.js +12 -0
- package/dist/db-utils.js +10 -1
- package/package.json +1 -1
package/dist/commands/create.js
CHANGED
|
@@ -406,6 +406,8 @@ exports.createCommand = new commander_1.Command('create')
|
|
|
406
406
|
let snapshotId;
|
|
407
407
|
let snapshotS3Key;
|
|
408
408
|
let localDumpPath;
|
|
409
|
+
let localSetupStartTime;
|
|
410
|
+
let localSetupDuration; // in seconds
|
|
409
411
|
const projectCache = loadProjectCache(process.cwd());
|
|
410
412
|
const needsLocalDbCopy = resolved.database.mode === 'copy' &&
|
|
411
413
|
resolved.database.url &&
|
|
@@ -500,6 +502,8 @@ exports.createCommand = new commander_1.Command('create')
|
|
|
500
502
|
console.log(chalk_1.default.dim(` Source: ${resolved.database.source}`));
|
|
501
503
|
}
|
|
502
504
|
console.log(chalk_1.default.dim(` URL: ${dbUrl.replace(/\/\/[^:]+:[^@]+@/, '//***:***@')}`));
|
|
505
|
+
// Start timing for local setup (dump + upload)
|
|
506
|
+
localSetupStartTime = Date.now();
|
|
503
507
|
const dumpSpinner = (0, ora_1.default)('Creating database dump...').start();
|
|
504
508
|
const dumpResult = await (0, db_utils_1.runLocalMongoDump)(dbUrl, {
|
|
505
509
|
onProgress: (msg) => dumpSpinner.text = msg,
|
|
@@ -528,6 +532,10 @@ exports.createCommand = new commander_1.Command('create')
|
|
|
528
532
|
uploadSpinner.succeed(chalk_1.default.green('Database snapshot uploaded'));
|
|
529
533
|
snapshotId = snapshotResult.snapshotId;
|
|
530
534
|
snapshotS3Key = snapshotResult.s3Key;
|
|
535
|
+
// Calculate local setup duration (dump + upload time)
|
|
536
|
+
if (localSetupStartTime) {
|
|
537
|
+
localSetupDuration = Math.round((Date.now() - localSetupStartTime) / 1000);
|
|
538
|
+
}
|
|
531
539
|
// Cleanup local dump since it's now in S3
|
|
532
540
|
if (localDumpPath)
|
|
533
541
|
(0, db_utils_1.cleanupDump)(localDumpPath);
|
|
@@ -570,6 +578,10 @@ exports.createCommand = new commander_1.Command('create')
|
|
|
570
578
|
};
|
|
571
579
|
}
|
|
572
580
|
const payload = buildPayload(payloadResolved, config, publicKey, privateKeyContent, configLoader);
|
|
581
|
+
// Add local setup duration if we did a local dump+upload
|
|
582
|
+
if (localSetupDuration) {
|
|
583
|
+
payload.localSetupDuration = localSetupDuration;
|
|
584
|
+
}
|
|
573
585
|
// Create genbox
|
|
574
586
|
const spinner = (0, ora_1.default)(`Creating Genbox '${name}'...`).start();
|
|
575
587
|
try {
|
package/dist/db-utils.js
CHANGED
|
@@ -117,11 +117,20 @@ function getMongoDumpInstallInstructions() {
|
|
|
117
117
|
async function runLocalMongoDump(sourceUrl, options = {}) {
|
|
118
118
|
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'genbox-dbdump-'));
|
|
119
119
|
const dumpPath = path.join(tempDir, 'dump.gz');
|
|
120
|
+
// Add timeout parameters to URI if not already present
|
|
121
|
+
// This prevents connection drops on large databases
|
|
122
|
+
let uriWithTimeout = sourceUrl;
|
|
123
|
+
const hasTimeout = sourceUrl.includes('socketTimeoutMS') || sourceUrl.includes('connectTimeoutMS');
|
|
124
|
+
if (!hasTimeout) {
|
|
125
|
+
const separator = sourceUrl.includes('?') ? '&' : '?';
|
|
126
|
+
uriWithTimeout = `${sourceUrl}${separator}socketTimeoutMS=300000&connectTimeoutMS=60000`;
|
|
127
|
+
}
|
|
120
128
|
return new Promise((resolve) => {
|
|
121
129
|
const args = [
|
|
122
|
-
`--uri=${
|
|
130
|
+
`--uri=${uriWithTimeout}`,
|
|
123
131
|
`--archive=${dumpPath}`,
|
|
124
132
|
'--gzip',
|
|
133
|
+
'--numParallelCollections=1', // Dump one collection at a time - more reliable for large DBs
|
|
125
134
|
];
|
|
126
135
|
// Add collection filters
|
|
127
136
|
if (options.collections && options.collections.length > 0) {
|