bs9 1.3.4 → 1.3.5
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/bin/bs9 +1 -1
- package/dist/bs9-d6mhpepe. +181 -0
- package/dist/bs9.js +1 -1
- package/package.json +1 -1
- package/src/commands/update.ts +24 -7
package/bin/bs9
CHANGED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { startCommand } from "../src/commands/start.js";
|
|
5
|
+
import { stopCommand } from "../src/commands/stop.js";
|
|
6
|
+
import { restartCommand } from "../src/commands/restart.js";
|
|
7
|
+
import { statusCommand } from "../src/commands/status.js";
|
|
8
|
+
import { logsCommand } from "../src/commands/logs.js";
|
|
9
|
+
import { monitCommand } from "../src/commands/monit.js";
|
|
10
|
+
import { webCommand } from "../src/commands/web.js";
|
|
11
|
+
import { alertCommand } from "../src/commands/alert.js";
|
|
12
|
+
import { exportCommand } from "../src/commands/export.js";
|
|
13
|
+
import { depsCommand } from "../src/commands/deps.js";
|
|
14
|
+
import { profileCommand } from "../src/commands/profile.js";
|
|
15
|
+
import { loadbalancerCommand } from "../src/loadbalancer/manager.js";
|
|
16
|
+
import { windowsCommand } from "../src/windows/service.js";
|
|
17
|
+
import { launchdCommand } from "../src/macos/launchd.js";
|
|
18
|
+
import { updateCommand } from "../src/commands/update.js";
|
|
19
|
+
import { dbpoolCommand } from "../src/database/pool.js";
|
|
20
|
+
import { advancedMonitoringCommand } from "../src/monitoring/advanced.js";
|
|
21
|
+
import { consulCommand } from "../src/discovery/consul.js";
|
|
22
|
+
|
|
23
|
+
const program = new Command();
|
|
24
|
+
|
|
25
|
+
program
|
|
26
|
+
.name("bs9")
|
|
27
|
+
.description("BS9 (Bun Sentinel 9) — Mission-critical process manager CLI")
|
|
28
|
+
.version("1.3.5");
|
|
29
|
+
|
|
30
|
+
program
|
|
31
|
+
.command("start")
|
|
32
|
+
.description("Start a process with hardened systemd unit")
|
|
33
|
+
.argument("<file>", "Application file to start")
|
|
34
|
+
.option("-n, --name <name>", "Service name")
|
|
35
|
+
.option("-p, --port <port>", "Port number", "3000")
|
|
36
|
+
.option("-h, --host <host>", "Host address", "localhost")
|
|
37
|
+
.option("--https", "Use HTTPS protocol")
|
|
38
|
+
.option("-e, --env <env>", "Environment variables (can be used multiple times)", (value, previous) => [...(previous || []), value])
|
|
39
|
+
.option("--otel", "Enable OpenTelemetry instrumentation", true)
|
|
40
|
+
.option("--prometheus", "Enable Prometheus metrics", true)
|
|
41
|
+
.option("--build", "Build TypeScript to JavaScript before starting")
|
|
42
|
+
.action(startCommand);
|
|
43
|
+
|
|
44
|
+
program
|
|
45
|
+
.command("stop")
|
|
46
|
+
.description("Stop a managed service")
|
|
47
|
+
.argument("<name>", "Service name")
|
|
48
|
+
.action(stopCommand);
|
|
49
|
+
|
|
50
|
+
program
|
|
51
|
+
.command("restart")
|
|
52
|
+
.description("Restart a managed service")
|
|
53
|
+
.argument("<name>", "Service name")
|
|
54
|
+
.action(restartCommand);
|
|
55
|
+
|
|
56
|
+
program
|
|
57
|
+
.command("status")
|
|
58
|
+
.description("Show status and SRE metrics for all services")
|
|
59
|
+
.option("-w, --watch", "Watch mode (refresh every 2s)")
|
|
60
|
+
.action(statusCommand);
|
|
61
|
+
|
|
62
|
+
program
|
|
63
|
+
.command("logs")
|
|
64
|
+
.description("Show logs for a service (via journalctl)")
|
|
65
|
+
.argument("<name>", "Service name")
|
|
66
|
+
.option("-f, --follow", "Follow logs")
|
|
67
|
+
.option("-n, --lines <number>", "Number of lines", "50")
|
|
68
|
+
.action(logsCommand);
|
|
69
|
+
|
|
70
|
+
program
|
|
71
|
+
.command("monit")
|
|
72
|
+
.description("Real-time terminal dashboard for all services")
|
|
73
|
+
.option("-r, --refresh <seconds>", "Refresh interval in seconds", "2")
|
|
74
|
+
.action(monitCommand);
|
|
75
|
+
|
|
76
|
+
program
|
|
77
|
+
.command("web")
|
|
78
|
+
.description("Start web-based monitoring dashboard")
|
|
79
|
+
.option("-p, --port <port>", "Port for web dashboard", "8080")
|
|
80
|
+
.option("-d, --detach", "Run in background")
|
|
81
|
+
.action(webCommand);
|
|
82
|
+
|
|
83
|
+
program
|
|
84
|
+
.command("alert")
|
|
85
|
+
.description("Configure alert thresholds and webhooks")
|
|
86
|
+
.option("--enable", "Enable alerts")
|
|
87
|
+
.option("--disable", "Disable alerts")
|
|
88
|
+
.option("--webhook <url>", "Set webhook URL for alerts")
|
|
89
|
+
.option("--cpu <percentage>", "CPU threshold percentage")
|
|
90
|
+
.option("--memory <percentage>", "Memory threshold percentage")
|
|
91
|
+
.option("--errorRate <percentage>", "Error rate threshold percentage")
|
|
92
|
+
.option("--uptime <percentage>", "Uptime threshold percentage")
|
|
93
|
+
.option("--cooldown <seconds>", "Alert cooldown period in seconds")
|
|
94
|
+
.option("--service <name>", "Configure alerts for specific service")
|
|
95
|
+
.option("--list", "List current alert configuration")
|
|
96
|
+
.option("--test", "Test webhook connectivity")
|
|
97
|
+
.action(alertCommand);
|
|
98
|
+
|
|
99
|
+
program
|
|
100
|
+
.command("export")
|
|
101
|
+
.description("Export historical metrics data")
|
|
102
|
+
.option("-f, --format <format>", "Export format (json|csv)", "json")
|
|
103
|
+
.option("-h, --hours <hours>", "Hours of data to export", "24")
|
|
104
|
+
.option("-o, --output <file>", "Output file path")
|
|
105
|
+
.option("-s, --service <name>", "Export specific service metrics")
|
|
106
|
+
.action(exportCommand);
|
|
107
|
+
|
|
108
|
+
program
|
|
109
|
+
.command("deps")
|
|
110
|
+
.description("Visualize service dependencies")
|
|
111
|
+
.option("-f, --format <format>", "Output format (text|dot|json)", "text")
|
|
112
|
+
.option("-o, --output <file>", "Output file path")
|
|
113
|
+
.action(depsCommand);
|
|
114
|
+
|
|
115
|
+
program
|
|
116
|
+
.command("profile")
|
|
117
|
+
.description("Performance profiling for services")
|
|
118
|
+
.option("-d, --duration <seconds>", "Profiling duration", "60")
|
|
119
|
+
.option("-i, --interval <ms>", "Sampling interval", "1000")
|
|
120
|
+
.option("-s, --service <name>", "Service name to profile")
|
|
121
|
+
.option("-o, --output <file>", "Output file path")
|
|
122
|
+
.action(profileCommand);
|
|
123
|
+
|
|
124
|
+
program
|
|
125
|
+
.command("loadbalancer")
|
|
126
|
+
.description("Load balancer management")
|
|
127
|
+
.argument("<action>", "Action to perform")
|
|
128
|
+
.option("-p, --port <port>", "Load balancer port", "8080")
|
|
129
|
+
.option("-a, --algorithm <type>", "Load balancing algorithm", "round-robin")
|
|
130
|
+
.option("-b, --backends <list>", "Backend servers (host:port,host:port)")
|
|
131
|
+
.option("--health-check", "Enable health checking", true)
|
|
132
|
+
.option("--health-path <path>", "Health check path", "/healthz")
|
|
133
|
+
.option("--health-interval <ms>", "Health check interval", "10000")
|
|
134
|
+
.action(loadbalancerCommand);
|
|
135
|
+
|
|
136
|
+
program
|
|
137
|
+
.command("dbpool")
|
|
138
|
+
.description("Database connection pool management")
|
|
139
|
+
.argument("<action>", "Action to perform")
|
|
140
|
+
.option("--host <host>", "Database host", "localhost")
|
|
141
|
+
.option("--port <port>", "Database port", "5432")
|
|
142
|
+
.option("--database <name>", "Database name", "testdb")
|
|
143
|
+
.option("--username <user>", "Database username", "user")
|
|
144
|
+
.option("--password <pass>", "Database password", "password")
|
|
145
|
+
.option("--max-connections <num>", "Maximum connections", "10")
|
|
146
|
+
.option("--min-connections <num>", "Minimum connections", "2")
|
|
147
|
+
.option("--concurrency <num>", "Test concurrency", "10")
|
|
148
|
+
.option("--iterations <num>", "Test iterations", "100")
|
|
149
|
+
.action(dbpoolCommand);
|
|
150
|
+
|
|
151
|
+
program
|
|
152
|
+
.command("update")
|
|
153
|
+
.description("Update BS9 to latest version")
|
|
154
|
+
.option("--check", "Check for updates without installing")
|
|
155
|
+
.option("--force", "Force update even if already latest")
|
|
156
|
+
.option("--rollback", "Rollback to previous version")
|
|
157
|
+
.option("--version <version>", "Update to specific version")
|
|
158
|
+
.action(updateCommand);
|
|
159
|
+
|
|
160
|
+
program
|
|
161
|
+
.command("advanced")
|
|
162
|
+
.description("Advanced monitoring dashboard")
|
|
163
|
+
.option("--port <port>", "Dashboard port", "8090")
|
|
164
|
+
.action(advancedMonitoringCommand);
|
|
165
|
+
|
|
166
|
+
program
|
|
167
|
+
.command("consul")
|
|
168
|
+
.description("Consul service discovery")
|
|
169
|
+
.argument("<action>", "Action to perform")
|
|
170
|
+
.option("--consul-url <url>", "Consul URL", "http://localhost:8500")
|
|
171
|
+
.option("--name <name>", "Service name")
|
|
172
|
+
.option("--id <id>", "Service ID")
|
|
173
|
+
.option("--address <address>", "Service address")
|
|
174
|
+
.option("--port <port>", "Service port")
|
|
175
|
+
.option("--tags <tags>", "Service tags (comma-separated)")
|
|
176
|
+
.option("--health-check <url>", "Health check URL")
|
|
177
|
+
.option("--meta <json>", "Service metadata (JSON)")
|
|
178
|
+
.option("--service <service>", "Service name for discovery")
|
|
179
|
+
.action(consulCommand);
|
|
180
|
+
|
|
181
|
+
program.parse();
|
package/dist/bs9.js
CHANGED
package/package.json
CHANGED
package/src/commands/update.ts
CHANGED
|
@@ -51,13 +51,22 @@ class BS9Updater {
|
|
|
51
51
|
|
|
52
52
|
private getCurrentVersion(): string {
|
|
53
53
|
try {
|
|
54
|
-
//
|
|
55
|
-
const
|
|
56
|
-
const content = fs.readFileSync(
|
|
57
|
-
const
|
|
54
|
+
// Get version from the CLI binary directly
|
|
55
|
+
const binaryPath = join(homedir(), '.bun', 'bin', 'bs9');
|
|
56
|
+
const content = fs.readFileSync(binaryPath, 'utf8');
|
|
57
|
+
const versionMatch = content.match(/version\("([^"]+)"\)/);
|
|
58
|
+
|
|
59
|
+
if (versionMatch && versionMatch[1]) {
|
|
60
|
+
return versionMatch[1];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Fallback to package.json in global installation
|
|
64
|
+
const packageJson = join(homedir(), '.bun', 'install', 'global', 'node_modules', 'bs9', 'package.json');
|
|
65
|
+
const pkgContent = fs.readFileSync(packageJson, 'utf8');
|
|
66
|
+
const pkg = JSON.parse(pkgContent);
|
|
58
67
|
return pkg.version;
|
|
59
68
|
} catch {
|
|
60
|
-
return '1.3.
|
|
69
|
+
return '1.3.4'; // Fallback version
|
|
61
70
|
}
|
|
62
71
|
}
|
|
63
72
|
|
|
@@ -68,7 +77,7 @@ class BS9Updater {
|
|
|
68
77
|
return data.version;
|
|
69
78
|
} catch (error) {
|
|
70
79
|
console.warn('⚠️ Failed to fetch latest version from npm, using fallback');
|
|
71
|
-
return '1.3.
|
|
80
|
+
return '1.3.4'; // Return current version as fallback
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
83
|
|
|
@@ -151,7 +160,7 @@ class BS9Updater {
|
|
|
151
160
|
return;
|
|
152
161
|
}
|
|
153
162
|
|
|
154
|
-
console.log(
|
|
163
|
+
console.log(`📦 Updating from ${currentVersion} to ${latestVersion}`);
|
|
155
164
|
|
|
156
165
|
// Use npm to update globally
|
|
157
166
|
console.log('📦 Installing latest version...');
|
|
@@ -159,6 +168,14 @@ class BS9Updater {
|
|
|
159
168
|
execSync(`bun install -g bs9@${latestVersion}`, { stdio: 'inherit' });
|
|
160
169
|
console.log('✅ BS9 updated successfully!');
|
|
161
170
|
console.log(` Version: ${latestVersion}`);
|
|
171
|
+
|
|
172
|
+
// Verify the update
|
|
173
|
+
const updatedVersion = this.getCurrentVersion();
|
|
174
|
+
if (updatedVersion === latestVersion) {
|
|
175
|
+
console.log('✅ Update verified successfully!');
|
|
176
|
+
} else {
|
|
177
|
+
console.log('⚠️ Update may require manual verification');
|
|
178
|
+
}
|
|
162
179
|
} catch (error) {
|
|
163
180
|
console.error('❌ Failed to update BS9:', error);
|
|
164
181
|
console.log('💡 Try: bun install -g bs9@latest');
|