genbox 1.0.6 → 1.0.8
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 +37 -40
- package/package.json +2 -1
package/dist/commands/status.js
CHANGED
|
@@ -118,6 +118,21 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
118
118
|
console.log(chalk_1.default.yellow('[WARN] Unable to connect to server. It may still be booting.'));
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
|
+
// Check for SSH connection errors (timeout, refused, etc.)
|
|
122
|
+
const sshErrors = [
|
|
123
|
+
'Operation timed out',
|
|
124
|
+
'Connection refused',
|
|
125
|
+
'Connection timed out',
|
|
126
|
+
'No route to host',
|
|
127
|
+
'Network is unreachable',
|
|
128
|
+
'ssh: connect to host',
|
|
129
|
+
];
|
|
130
|
+
if (sshErrors.some(err => status.includes(err))) {
|
|
131
|
+
console.log(chalk_1.default.yellow('[INFO] Server is still initializing - SSH is not yet available.'));
|
|
132
|
+
console.log(chalk_1.default.dim(' This is normal for newly created servers.'));
|
|
133
|
+
console.log(chalk_1.default.dim(' Please wait 1-2 minutes and try again.'));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
121
136
|
if (status.includes('running')) {
|
|
122
137
|
// Get elapsed time since server boot
|
|
123
138
|
const uptime = sshExec(target.ipAddress, keyPath, "cat /proc/uptime 2>/dev/null | cut -d' ' -f1 | cut -d'.' -f1");
|
|
@@ -139,24 +154,20 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
139
154
|
}
|
|
140
155
|
}
|
|
141
156
|
else if (status.includes('done')) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const cloudInitTotal = sshExec(target.ipAddress, keyPath, "sudo grep 'Cloud-init.*finished' /var/log/cloud-init-output.log 2>/dev/null | tail -1");
|
|
151
|
-
if (cloudInitTotal) {
|
|
152
|
-
console.log(` ${cloudInitTotal}`);
|
|
157
|
+
// Get uptime for timing display
|
|
158
|
+
const uptimeRaw = sshExec(target.ipAddress, keyPath, "cat /proc/uptime 2>/dev/null | cut -d' ' -f1");
|
|
159
|
+
let uptimeFormatted = '';
|
|
160
|
+
if (uptimeRaw) {
|
|
161
|
+
const uptimeSecs = Math.floor(parseFloat(uptimeRaw));
|
|
162
|
+
const mins = Math.floor(uptimeSecs / 60);
|
|
163
|
+
const secs = uptimeSecs % 60;
|
|
164
|
+
uptimeFormatted = mins > 0 ? `${mins}m ${secs}s` : `${secs}s`;
|
|
153
165
|
}
|
|
166
|
+
console.log(chalk_1.default.green(`[SUCCESS] Cloud-init completed!${uptimeFormatted ? ` (${uptimeFormatted})` : ''}`));
|
|
154
167
|
console.log('');
|
|
155
|
-
// Show Database Stats -
|
|
156
|
-
console.log(chalk_1.default.blue('[INFO] === Database Stats ==='));
|
|
168
|
+
// Show Database Stats - only if configured
|
|
157
169
|
let dbContainer = '';
|
|
158
170
|
let dbName = '';
|
|
159
|
-
// Try to load database settings from config
|
|
160
171
|
if ((0, config_1.hasConfig)()) {
|
|
161
172
|
try {
|
|
162
173
|
const config = (0, config_1.loadConfig)();
|
|
@@ -164,17 +175,13 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
164
175
|
dbName = config.database.name;
|
|
165
176
|
dbContainer = config.database.container || `${config.project_name}-mongodb`;
|
|
166
177
|
}
|
|
167
|
-
else {
|
|
168
|
-
// Default from project name
|
|
169
|
-
dbName = config.project_name;
|
|
170
|
-
dbContainer = `${config.project_name}-mongodb`;
|
|
171
|
-
}
|
|
172
178
|
}
|
|
173
179
|
catch {
|
|
174
180
|
// Config load failed
|
|
175
181
|
}
|
|
176
182
|
}
|
|
177
183
|
if (dbContainer && dbName) {
|
|
184
|
+
console.log(chalk_1.default.blue('[INFO] === Database Stats ==='));
|
|
178
185
|
const dbStats = sshExec(target.ipAddress, keyPath, `docker exec ${dbContainer} mongosh --quiet ${dbName} --eval 'print("Collections: " + db.getCollectionNames().length); db.getCollectionNames().slice(0, 5).forEach(c => print(" " + c + ": " + db[c].countDocuments()))' 2>/dev/null || echo "Unable to fetch stats"`, 15);
|
|
179
186
|
if (dbStats) {
|
|
180
187
|
const lines = dbStats.split('\n');
|
|
@@ -184,23 +191,17 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
184
191
|
}
|
|
185
192
|
}
|
|
186
193
|
}
|
|
194
|
+
console.log('');
|
|
187
195
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
// Show Docker containers status
|
|
194
|
-
console.log(chalk_1.default.blue('[INFO] === Docker Services ==='));
|
|
195
|
-
const dockerStatus = sshExec(target.ipAddress, keyPath, 'docker ps --format "table {{.Names}}\\t{{.Status}}" 2>/dev/null || echo "No containers running"', 10);
|
|
196
|
-
if (dockerStatus) {
|
|
196
|
+
// Show Docker containers status - only if containers are running
|
|
197
|
+
const dockerStatus = sshExec(target.ipAddress, keyPath, 'docker ps --format "{{.Names}}\\t{{.Status}}" 2>/dev/null', 10);
|
|
198
|
+
if (dockerStatus && dockerStatus.trim()) {
|
|
199
|
+
console.log(chalk_1.default.blue('[INFO] === Docker Services ==='));
|
|
200
|
+
console.log('NAMES\tSTATUS');
|
|
197
201
|
console.log(dockerStatus);
|
|
202
|
+
console.log('');
|
|
198
203
|
}
|
|
199
|
-
console.log('');
|
|
200
|
-
// Show Health Checks - from config services
|
|
201
|
-
console.log(chalk_1.default.blue('[INFO] === Health Checks ==='));
|
|
202
204
|
let healthChecks = [];
|
|
203
|
-
// Try to load services from genbox.yaml config
|
|
204
205
|
if ((0, config_1.hasConfig)()) {
|
|
205
206
|
try {
|
|
206
207
|
const config = (0, config_1.loadConfig)();
|
|
@@ -215,15 +216,11 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
218
|
catch {
|
|
218
|
-
// Config load failed
|
|
219
|
+
// Config load failed
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
console.log(chalk_1.default.dim(' No services configured in genbox.yaml'));
|
|
224
|
-
console.log(chalk_1.default.dim(' Run `genbox init` to configure services'));
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
222
|
+
if (healthChecks.length > 0) {
|
|
223
|
+
console.log(chalk_1.default.blue('[INFO] === Health Checks ==='));
|
|
227
224
|
for (const check of healthChecks) {
|
|
228
225
|
const result = sshExec(target.ipAddress, keyPath, `curl -s -o /dev/null -w '%{http_code}' "${check.url}" 2>/dev/null || echo "N/A"`, 5);
|
|
229
226
|
const statusCode = result.trim();
|
|
@@ -234,8 +231,8 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
234
231
|
console.log(` ${chalk_1.default.red('✗')} ${check.name}: ${statusCode}`);
|
|
235
232
|
}
|
|
236
233
|
}
|
|
234
|
+
console.log('');
|
|
237
235
|
}
|
|
238
|
-
console.log('');
|
|
239
236
|
// Show URLs if available
|
|
240
237
|
if (target.urls && Object.keys(target.urls).length > 0) {
|
|
241
238
|
console.log(chalk_1.default.blue('[INFO] === Service URLs ==='));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genbox",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Genbox CLI - AI-Powered Development Environments",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"chalk": "^5.6.2",
|
|
60
60
|
"commander": "^14.0.2",
|
|
61
61
|
"dotenv": "^17.2.3",
|
|
62
|
+
"fast-glob": "^3.3.3",
|
|
62
63
|
"inquirer": "^13.0.2",
|
|
63
64
|
"js-yaml": "^4.1.1",
|
|
64
65
|
"ora": "^9.0.0"
|