genbox 1.0.35 → 1.0.37
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/status.js +51 -5
- package/package.json +1 -1
package/dist/commands/status.js
CHANGED
|
@@ -193,10 +193,42 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
193
193
|
const dbStatus = target.status; // 'provisioning' | 'running' | 'error' etc.
|
|
194
194
|
const setupDuration = target.setupDuration;
|
|
195
195
|
const setupCompletedAt = target.setupCompletedAt;
|
|
196
|
-
// If DB says RUNNING
|
|
197
|
-
if (dbStatus === 'running'
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
// If DB says RUNNING, setup is complete (use DB as source of truth)
|
|
197
|
+
if (dbStatus === 'running') {
|
|
198
|
+
if (setupCompletedAt && setupDuration) {
|
|
199
|
+
console.log(chalk_1.default.green(`[SUCCESS] Setup completed! (took ${formatDuration(setupDuration)})`));
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
console.log(chalk_1.default.green(`[SUCCESS] Genbox is running`));
|
|
203
|
+
}
|
|
204
|
+
console.log('');
|
|
205
|
+
// Show billing info
|
|
206
|
+
const billing = {
|
|
207
|
+
creditsPerHour: target.creditsPerHour || 1,
|
|
208
|
+
totalCreditsUsed: target.totalCreditsUsed || 0,
|
|
209
|
+
totalHoursUsed: target.totalHoursUsed || 0,
|
|
210
|
+
currentHourEnd: target.currentHourEnd,
|
|
211
|
+
lastActivityAt: target.lastActivityAt,
|
|
212
|
+
autoDestroyOnInactivity: target.autoDestroyOnInactivity ?? true,
|
|
213
|
+
};
|
|
214
|
+
const now = new Date();
|
|
215
|
+
const minutesUntilBilling = billing.currentHourEnd
|
|
216
|
+
? Math.max(0, Math.ceil((new Date(billing.currentHourEnd).getTime() - now.getTime()) / (60 * 1000)))
|
|
217
|
+
: 0;
|
|
218
|
+
const minutesInactive = billing.lastActivityAt
|
|
219
|
+
? Math.floor((now.getTime() - new Date(billing.lastActivityAt).getTime()) / (60 * 1000))
|
|
220
|
+
: 0;
|
|
221
|
+
console.log(chalk_1.default.blue('[INFO] === Billing ==='));
|
|
222
|
+
console.log(` Size: ${target.size} (${billing.creditsPerHour} credit${billing.creditsPerHour > 1 ? 's' : ''}/hr)`);
|
|
223
|
+
console.log(` Current hour ends in: ${chalk_1.default.cyan(minutesUntilBilling + ' min')}`);
|
|
224
|
+
console.log(` Last activity: ${minutesInactive < 1 ? 'just now' : minutesInactive + ' min ago'}`);
|
|
225
|
+
console.log(` Total: ${billing.totalHoursUsed} hour${billing.totalHoursUsed !== 1 ? 's' : ''}, ${billing.totalCreditsUsed} credit${billing.totalCreditsUsed !== 1 ? 's' : ''}`);
|
|
226
|
+
if (billing.autoDestroyOnInactivity) {
|
|
227
|
+
const minutesUntilDestroy = Math.max(0, 60 - minutesInactive);
|
|
228
|
+
if (minutesInactive >= 45) {
|
|
229
|
+
console.log(chalk_1.default.yellow(` Auto-destroy in: ${minutesUntilDestroy} min (inactive)`));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
200
232
|
console.log('');
|
|
201
233
|
// Show Docker containers status
|
|
202
234
|
const dockerStatus = sshExec(target.ipAddress, keyPath, 'docker ps --format "{{.Names}}\\t{{.Status}}" 2>/dev/null', 10);
|
|
@@ -294,7 +326,21 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
294
326
|
console.log(chalk_1.default.dim(' Run `genbox connect` to investigate.'));
|
|
295
327
|
return;
|
|
296
328
|
}
|
|
297
|
-
//
|
|
329
|
+
// If DB says TERMINATED
|
|
330
|
+
if (dbStatus === 'terminated') {
|
|
331
|
+
const destroyReason = target.destroyReason;
|
|
332
|
+
console.log(chalk_1.default.red(`[TERMINATED] Genbox has been destroyed`));
|
|
333
|
+
if (destroyReason) {
|
|
334
|
+
console.log(chalk_1.default.dim(` Reason: ${destroyReason}`));
|
|
335
|
+
}
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
// If DB says STOPPED
|
|
339
|
+
if (dbStatus === 'stopped') {
|
|
340
|
+
console.log(chalk_1.default.yellow('[STOPPED] Genbox is stopped'));
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
// Fallback: try legacy cloud-init check for backwards compatibility (should rarely reach here)
|
|
298
344
|
let status = sshExec(target.ipAddress, keyPath, 'cloud-init status 2>&1');
|
|
299
345
|
if (!status || status.includes('not found')) {
|
|
300
346
|
// No cloud-init, check our status file
|