bs9 1.0.0 → 1.1.0

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/README.md CHANGED
@@ -1,6 +1,12 @@
1
- # BS9 (Bun Sentinel 9)
1
+ # BS9 (Bun Sentinel 9) 🚀
2
2
 
3
- > Mission-critical process manager CLI with real-time monitoring dashboard, historical metrics storage, alert system, container support, and enterprise-grade security.
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/bs9/bs9)
5
+ [![Security](https://img.shields.io/badge/security-Enterprise-green.svg)](SECURITY.md)
6
+ [![Production Ready](https://img.shields.io/badge/production-Ready-brightgreen.svg)](PRODUCTION.md)
7
+ [![Cross-Platform](https://img.shields.io/badge/platform-Linux%20%7C%20macOS%20%7C%20Windows-lightgrey.svg)](https://github.com/bs9/bs9)
8
+
9
+ **Enterprise-grade, mission-critical process manager for Bun applications with built-in security, monitoring, and observability. Works on Windows, macOS, and Linux.**
4
10
 
5
11
  ---
6
12
 
@@ -8,7 +14,7 @@
8
14
 
9
15
  ```bash
10
16
  # One-click installer (installs Bun + BS9)
11
- curl -fsSL https://raw.githubusercontent.com/xarhang/bs9/main/setup.sh | bash
17
+ curl -fsSL https://raw.githubusercontent.com/xarhang/bs9/setup.sh | bash
12
18
 
13
19
  # Or manual install
14
20
  git clone https://github.com/xarhang/bs9.git
@@ -20,14 +26,43 @@ chmod +x ~/.local/bin/bs9
20
26
 
21
27
  ---
22
28
 
29
+ ### Platform Support
30
+
31
+ BS9 supports all major platforms with native service management:
32
+
33
+ #### 🐧 Linux
34
+ - **Service Manager**: Systemd (user-mode)
35
+ - **Features**: Advanced security hardening, resource limits, sandboxing
36
+ - **Commands**: All standard commands available
37
+
38
+ #### 🍎 macOS
39
+ - **Service Manager**: Launchd
40
+ - **Features**: Native macOS integration, automatic recovery
41
+ - **Commands**: Standard commands + `bs9 macos` for launchd management
42
+
43
+ #### 🪟 Windows
44
+ - **Service Manager**: Windows Services
45
+ - **Features**: PowerShell automation, event log integration
46
+ - **Commands**: Standard commands + `bs9 windows` for service management
47
+
48
+ ```bash
49
+ # Check your platform
50
+ bs9 platform
51
+
52
+ # Platform-specific service management
53
+ bs9 macos create --name my-app --file app.js # macOS
54
+ bs9 windows create --name my-app --file app.js # Windows
55
+ ```
56
+
23
57
  ## 📋 Complete CLI Commands
24
58
 
25
59
  ### Service Management
26
60
  ```bash
27
- # Start service with TypeScript JIT/AOT support
28
- bs9 start app.js # JavaScript app
29
- bs9 start app.ts --build # TypeScript AOT compilation
30
- bs9 start app.ts --name myapp --port 8080 --env NODE_ENV=production
61
+ # Start service with flexible host and protocol options
62
+ bs9 start app.js # Default: localhost:3000, HTTP
63
+ bs9 start app.js --host 0.0.0.0 --port 8080 # Custom host and port
64
+ bs9 start app.js --host 192.168.1.100 --https # Custom host with HTTPS
65
+ bs9 start app.ts --build --name myapp --port 8080 --env NODE_ENV=production --host 0.0.0.0 --https
31
66
 
32
67
  # Service lifecycle
33
68
  bs9 stop myapp
@@ -234,8 +269,8 @@ docker-compose up -d
234
269
  kubectl apply -f src/k8s/bs9-deployment.yaml
235
270
 
236
271
  # Check deployment
272
+ kubectl get deployments -n bs9-system
237
273
  kubectl get pods -n bs9-system
238
- kubectl get services -n bs9-system
239
274
  ```
240
275
 
241
276
  ### K8s Features
@@ -528,5 +563,58 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines.
528
563
 
529
564
  - **GitHub**: https://github.com/xarhang/bs9
530
565
  - **Issues**: https://github.com/xarhang/bs9/issues
531
- - **Documentation**: https://github.com/xarhang/bs9/wiki
532
566
  - **Discussions**: https://github.com/xarhang/bs9/discussions
567
+ - **Security**: security@bs9.dev
568
+ - **Enterprise**: enterprise@bs9.dev
569
+
570
+ ## 🔒 Security
571
+
572
+ BS9 is built with security as a primary concern:
573
+
574
+ ### Built-in Security Features
575
+ - **Input Validation**: Path traversal protection, command injection prevention
576
+ - **Runtime Security**: Process isolation, resource limits, security auditing
577
+ - **Platform Hardening**: Native security integration (systemd, launchd, Windows services)
578
+ - **Web Security**: Session token authentication, XSS protection
579
+ - **Database Security**: SQL injection prevention, connection validation
580
+ - **Network Security**: Header sanitization, rate limiting
581
+
582
+ ### Security Best Practices
583
+ ```bash
584
+ # Use secure service names
585
+ bs9 start app.js --name my-secure-app
586
+
587
+ # Bind to specific interfaces
588
+ bs9 start app.js --host 127.0.0.1 --port 3000
589
+
590
+ # Use HTTPS in production
591
+ bs9 start app.js --https --host 0.0.0.0 --port 8443
592
+
593
+ # Enable security auditing
594
+ export BS9_AUDIT_LOGGING=true
595
+ bs9 start app.js
596
+
597
+ # Secure web dashboard
598
+ bs9 web --port 8080 # Generates secure session token
599
+ ```
600
+
601
+ ### Security Documentation
602
+ - **[Security Policy](SECURITY.md)** - Complete security documentation
603
+ - **[Production Security Guide](PRODUCTION.md#security-hardening)** - Production security hardening
604
+
605
+ ### Security Checklist
606
+ - [ ] Review service configurations
607
+ - [ ] Enable security audit logging
608
+ - [ ] Use proper file permissions
609
+ - [ ] Configure network firewalls
610
+ - [ ] Monitor security logs
611
+ - [ ] Regular security updates
612
+
613
+ ## 📚 Documentation
614
+
615
+ - **[Production Guide](PRODUCTION.md)** - Production deployment and operations
616
+ - **[Security Policy](SECURITY.md)** - Security features and vulnerability reporting
617
+ - **[Architecture](ARCHITECTURE.md)** - System architecture and design
618
+ - **[Installation Guide](INSTALL.md)** - Detailed installation instructions
619
+ - **[Contributing](CONTRIBUTING.md)** - Development and contribution guidelines
620
+ - **[Changelog](CHANGELOG.md)** - Version history and roadmap
package/bin/bs9 CHANGED
@@ -10,6 +10,12 @@ import { monitCommand } from "../src/commands/monit.js";
10
10
  import { webCommand } from "../src/commands/web.js";
11
11
  import { alertCommand } from "../src/commands/alert.js";
12
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 { dbpoolCommand } from "../src/database/pool.js";
13
19
 
14
20
  const program = new Command();
15
21
 
@@ -21,13 +27,15 @@ program
21
27
  program
22
28
  .command("start")
23
29
  .description("Start a process with hardened systemd unit")
24
- .argument("<file>", "Script or executable to run")
25
- .option("-n, --name <name>", "Service name (defaults to filename)")
26
- .option("-p, --port <port>", "Port to expose (for metrics/health)", "3000")
27
- .option("--env <env...>", "Environment variables (KEY=VALUE)")
28
- .option("--no-otel", "Disable automatic OpenTelemetry injection")
29
- .option("--no-prometheus", "Disable automatic Prometheus metrics")
30
- .option("--build", "Build TypeScript to optimized JavaScript for production (AOT)")
30
+ .argument("<file>", "Application file to start")
31
+ .option("-n, --name <name>", "Service name")
32
+ .option("-p, --port <port>", "Port number", "3000")
33
+ .option("-h, --host <host>", "Host address", "localhost")
34
+ .option("--https", "Use HTTPS protocol")
35
+ .option("-e, --env <env>", "Environment variables (can be used multiple times)", (value, previous) => [...(previous || []), value])
36
+ .option("--otel", "Enable OpenTelemetry instrumentation", true)
37
+ .option("--prometheus", "Enable Prometheus metrics", true)
38
+ .option("--build", "Build TypeScript to JavaScript before starting")
31
39
  .action(startCommand);
32
40
 
33
41
  program
@@ -94,4 +102,47 @@ program
94
102
  .option("-s, --service <name>", "Export specific service metrics")
95
103
  .action(exportCommand);
96
104
 
105
+ program
106
+ .command("deps")
107
+ .description("Visualize service dependencies")
108
+ .option("-f, --format <format>", "Output format (text|dot|json)", "text")
109
+ .option("-o, --output <file>", "Output file path")
110
+ .action(depsCommand);
111
+
112
+ program
113
+ .command("profile")
114
+ .description("Performance profiling for services")
115
+ .option("-d, --duration <seconds>", "Profiling duration", "60")
116
+ .option("-i, --interval <ms>", "Sampling interval", "1000")
117
+ .option("-s, --service <name>", "Service name to profile")
118
+ .option("-o, --output <file>", "Output file path")
119
+ .action(profileCommand);
120
+
121
+ program
122
+ .command("loadbalancer")
123
+ .description("Load balancer management")
124
+ .argument("<action>", "Action to perform")
125
+ .option("-p, --port <port>", "Load balancer port", "8080")
126
+ .option("-a, --algorithm <type>", "Load balancing algorithm", "round-robin")
127
+ .option("-b, --backends <list>", "Backend servers (host:port,host:port)")
128
+ .option("--health-check", "Enable health checking", true)
129
+ .option("--health-path <path>", "Health check path", "/healthz")
130
+ .option("--health-interval <ms>", "Health check interval", "10000")
131
+ .action(loadbalancerCommand);
132
+
133
+ program
134
+ .command("dbpool")
135
+ .description("Database connection pool management")
136
+ .argument("<action>", "Action to perform")
137
+ .option("--host <host>", "Database host", "localhost")
138
+ .option("--port <port>", "Database port", "5432")
139
+ .option("--database <name>", "Database name", "testdb")
140
+ .option("--username <user>", "Database username", "user")
141
+ .option("--password <pass>", "Database password", "password")
142
+ .option("--max-connections <num>", "Maximum connections", "10")
143
+ .option("--min-connections <num>", "Minimum connections", "2")
144
+ .option("--concurrency <num>", "Test concurrency", "10")
145
+ .option("--iterations <num>", "Test iterations", "100")
146
+ .action(dbpoolCommand);
147
+
97
148
  program.parse();
@@ -0,0 +1,148 @@
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 { dbpoolCommand } from "../src/database/pool.js";
19
+
20
+ const program = new Command();
21
+
22
+ program
23
+ .name("bs9")
24
+ .description("BS9 (Bun Sentinel 9) — Mission-critical process manager CLI")
25
+ .version("1.0.0");
26
+
27
+ program
28
+ .command("start")
29
+ .description("Start a process with hardened systemd unit")
30
+ .argument("<file>", "Application file to start")
31
+ .option("-n, --name <name>", "Service name")
32
+ .option("-p, --port <port>", "Port number", "3000")
33
+ .option("-h, --host <host>", "Host address", "localhost")
34
+ .option("--https", "Use HTTPS protocol")
35
+ .option("-e, --env <env>", "Environment variables (can be used multiple times)", (value, previous) => [...(previous || []), value])
36
+ .option("--otel", "Enable OpenTelemetry instrumentation", true)
37
+ .option("--prometheus", "Enable Prometheus metrics", true)
38
+ .option("--build", "Build TypeScript to JavaScript before starting")
39
+ .action(startCommand);
40
+
41
+ program
42
+ .command("stop")
43
+ .description("Stop a managed service")
44
+ .argument("<name>", "Service name")
45
+ .action(stopCommand);
46
+
47
+ program
48
+ .command("restart")
49
+ .description("Restart a managed service")
50
+ .argument("<name>", "Service name")
51
+ .action(restartCommand);
52
+
53
+ program
54
+ .command("status")
55
+ .description("Show status and SRE metrics for all services")
56
+ .option("-w, --watch", "Watch mode (refresh every 2s)")
57
+ .action(statusCommand);
58
+
59
+ program
60
+ .command("logs")
61
+ .description("Show logs for a service (via journalctl)")
62
+ .argument("<name>", "Service name")
63
+ .option("-f, --follow", "Follow logs")
64
+ .option("-n, --lines <number>", "Number of lines", "50")
65
+ .action(logsCommand);
66
+
67
+ program
68
+ .command("monit")
69
+ .description("Real-time terminal dashboard for all services")
70
+ .option("-r, --refresh <seconds>", "Refresh interval in seconds", "2")
71
+ .action(monitCommand);
72
+
73
+ program
74
+ .command("web")
75
+ .description("Start web-based monitoring dashboard")
76
+ .option("-p, --port <port>", "Port for web dashboard", "8080")
77
+ .option("-d, --detach", "Run in background")
78
+ .action(webCommand);
79
+
80
+ program
81
+ .command("alert")
82
+ .description("Configure alert thresholds and webhooks")
83
+ .option("--enable", "Enable alerts")
84
+ .option("--disable", "Disable alerts")
85
+ .option("--webhook <url>", "Set webhook URL for alerts")
86
+ .option("--cpu <percentage>", "CPU threshold percentage")
87
+ .option("--memory <percentage>", "Memory threshold percentage")
88
+ .option("--errorRate <percentage>", "Error rate threshold percentage")
89
+ .option("--uptime <percentage>", "Uptime threshold percentage")
90
+ .option("--cooldown <seconds>", "Alert cooldown period in seconds")
91
+ .option("--service <name>", "Configure alerts for specific service")
92
+ .option("--list", "List current alert configuration")
93
+ .option("--test", "Test webhook connectivity")
94
+ .action(alertCommand);
95
+
96
+ program
97
+ .command("export")
98
+ .description("Export historical metrics data")
99
+ .option("-f, --format <format>", "Export format (json|csv)", "json")
100
+ .option("-h, --hours <hours>", "Hours of data to export", "24")
101
+ .option("-o, --output <file>", "Output file path")
102
+ .option("-s, --service <name>", "Export specific service metrics")
103
+ .action(exportCommand);
104
+
105
+ program
106
+ .command("deps")
107
+ .description("Visualize service dependencies")
108
+ .option("-f, --format <format>", "Output format (text|dot|json)", "text")
109
+ .option("-o, --output <file>", "Output file path")
110
+ .action(depsCommand);
111
+
112
+ program
113
+ .command("profile")
114
+ .description("Performance profiling for services")
115
+ .option("-d, --duration <seconds>", "Profiling duration", "60")
116
+ .option("-i, --interval <ms>", "Sampling interval", "1000")
117
+ .option("-s, --service <name>", "Service name to profile")
118
+ .option("-o, --output <file>", "Output file path")
119
+ .action(profileCommand);
120
+
121
+ program
122
+ .command("loadbalancer")
123
+ .description("Load balancer management")
124
+ .argument("<action>", "Action to perform")
125
+ .option("-p, --port <port>", "Load balancer port", "8080")
126
+ .option("-a, --algorithm <type>", "Load balancing algorithm", "round-robin")
127
+ .option("-b, --backends <list>", "Backend servers (host:port,host:port)")
128
+ .option("--health-check", "Enable health checking", true)
129
+ .option("--health-path <path>", "Health check path", "/healthz")
130
+ .option("--health-interval <ms>", "Health check interval", "10000")
131
+ .action(loadbalancerCommand);
132
+
133
+ program
134
+ .command("dbpool")
135
+ .description("Database connection pool management")
136
+ .argument("<action>", "Action to perform")
137
+ .option("--host <host>", "Database host", "localhost")
138
+ .option("--port <port>", "Database port", "5432")
139
+ .option("--database <name>", "Database name", "testdb")
140
+ .option("--username <user>", "Database username", "user")
141
+ .option("--password <pass>", "Database password", "password")
142
+ .option("--max-connections <num>", "Maximum connections", "10")
143
+ .option("--min-connections <num>", "Minimum connections", "2")
144
+ .option("--concurrency <num>", "Test concurrency", "10")
145
+ .option("--iterations <num>", "Test iterations", "100")
146
+ .action(dbpoolCommand);
147
+
148
+ program.parse();
@@ -0,0 +1,144 @@
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 { dbpoolCommand } from "../src/database/pool.js";
17
+
18
+ const program = new Command();
19
+
20
+ program
21
+ .name("bs9")
22
+ .description("BS9 (Bun Sentinel 9) — Mission-critical process manager CLI")
23
+ .version("1.0.0");
24
+
25
+ program
26
+ .command("start")
27
+ .description("Start a process with hardened systemd unit")
28
+ .argument("<file>", "Script or executable to run")
29
+ .option("-n, --name <name>", "Service name (defaults to filename)")
30
+ .option("-p, --port <port>", "Port to expose (for metrics/health)", "3000")
31
+ .option("--env <env...>", "Environment variables (KEY=VALUE)")
32
+ .option("--no-otel", "Disable automatic OpenTelemetry injection")
33
+ .option("--no-prometheus", "Disable automatic Prometheus metrics")
34
+ .option("--build", "Build TypeScript to optimized JavaScript for production (AOT)")
35
+ .action(startCommand);
36
+
37
+ program
38
+ .command("stop")
39
+ .description("Stop a managed service")
40
+ .argument("<name>", "Service name")
41
+ .action(stopCommand);
42
+
43
+ program
44
+ .command("restart")
45
+ .description("Restart a managed service")
46
+ .argument("<name>", "Service name")
47
+ .action(restartCommand);
48
+
49
+ program
50
+ .command("status")
51
+ .description("Show status and SRE metrics for all services")
52
+ .option("-w, --watch", "Watch mode (refresh every 2s)")
53
+ .action(statusCommand);
54
+
55
+ program
56
+ .command("logs")
57
+ .description("Show logs for a service (via journalctl)")
58
+ .argument("<name>", "Service name")
59
+ .option("-f, --follow", "Follow logs")
60
+ .option("-n, --lines <number>", "Number of lines", "50")
61
+ .action(logsCommand);
62
+
63
+ program
64
+ .command("monit")
65
+ .description("Real-time terminal dashboard for all services")
66
+ .option("-r, --refresh <seconds>", "Refresh interval in seconds", "2")
67
+ .action(monitCommand);
68
+
69
+ program
70
+ .command("web")
71
+ .description("Start web-based monitoring dashboard")
72
+ .option("-p, --port <port>", "Port for web dashboard", "8080")
73
+ .option("-d, --detach", "Run in background")
74
+ .action(webCommand);
75
+
76
+ program
77
+ .command("alert")
78
+ .description("Configure alert thresholds and webhooks")
79
+ .option("--enable", "Enable alerts")
80
+ .option("--disable", "Disable alerts")
81
+ .option("--webhook <url>", "Set webhook URL for alerts")
82
+ .option("--cpu <percentage>", "CPU threshold percentage")
83
+ .option("--memory <percentage>", "Memory threshold percentage")
84
+ .option("--errorRate <percentage>", "Error rate threshold percentage")
85
+ .option("--uptime <percentage>", "Uptime threshold percentage")
86
+ .option("--cooldown <seconds>", "Alert cooldown period in seconds")
87
+ .option("--service <name>", "Configure alerts for specific service")
88
+ .option("--list", "List current alert configuration")
89
+ .option("--test", "Test webhook connectivity")
90
+ .action(alertCommand);
91
+
92
+ program
93
+ .command("export")
94
+ .description("Export historical metrics data")
95
+ .option("-f, --format <format>", "Export format (json|csv)", "json")
96
+ .option("-h, --hours <hours>", "Hours of data to export", "24")
97
+ .option("-o, --output <file>", "Output file path")
98
+ .option("-s, --service <name>", "Export specific service metrics")
99
+ .action(exportCommand);
100
+
101
+ program
102
+ .command("deps")
103
+ .description("Visualize service dependencies")
104
+ .option("-f, --format <format>", "Output format (text|dot|json)", "text")
105
+ .option("-o, --output <file>", "Output file path")
106
+ .action(depsCommand);
107
+
108
+ program
109
+ .command("profile")
110
+ .description("Performance profiling for services")
111
+ .option("-d, --duration <seconds>", "Profiling duration", "60")
112
+ .option("-i, --interval <ms>", "Sampling interval", "1000")
113
+ .option("-s, --service <name>", "Service name to profile")
114
+ .option("-o, --output <file>", "Output file path")
115
+ .action(profileCommand);
116
+
117
+ program
118
+ .command("loadbalancer")
119
+ .description("Load balancer management")
120
+ .argument("<action>", "Action to perform")
121
+ .option("-p, --port <port>", "Load balancer port", "8080")
122
+ .option("-a, --algorithm <type>", "Load balancing algorithm", "round-robin")
123
+ .option("-b, --backends <list>", "Backend servers (host:port,host:port)")
124
+ .option("--health-check", "Enable health checking", true)
125
+ .option("--health-path <path>", "Health check path", "/healthz")
126
+ .option("--health-interval <ms>", "Health check interval", "10000")
127
+ .action(loadbalancerCommand);
128
+
129
+ program
130
+ .command("dbpool")
131
+ .description("Database connection pool management")
132
+ .argument("<action>", "Action to perform")
133
+ .option("--host <host>", "Database host", "localhost")
134
+ .option("--port <port>", "Database port", "5432")
135
+ .option("--database <name>", "Database name", "testdb")
136
+ .option("--username <user>", "Database username", "user")
137
+ .option("--password <pass>", "Database password", "password")
138
+ .option("--max-connections <num>", "Maximum connections", "10")
139
+ .option("--min-connections <num>", "Minimum connections", "2")
140
+ .option("--concurrency <num>", "Test concurrency", "10")
141
+ .option("--iterations <num>", "Test iterations", "100")
142
+ .action(dbpoolCommand);
143
+
144
+ program.parse();