bs9 1.5.7 → 1.5.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bs9",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "description": "Bun Sentinel 9 - High-performance, non-root process manager for Bun",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -90,16 +90,27 @@ async function handleMultiServiceStart(file: string, options: StartOptions): Pro
90
90
  const results = await Promise.allSettled(
91
91
  services.map(async (serviceName) => {
92
92
  try {
93
- // For multi-service, we need to find the service file
94
- const serviceFile = findServiceFile(serviceName);
95
- if (!serviceFile) {
96
- throw new Error(`Service file not found for: ${serviceName}`);
97
- }
93
+ const platformInfo = getPlatformInfo();
94
+
95
+ // First check if service already exists
96
+ const serviceExists = await checkServiceExists(serviceName, platformInfo);
98
97
 
99
- await handleSingleServiceStart(serviceFile, { ...options, name: serviceName });
100
- return { service: serviceName, status: 'success', error: null };
98
+ if (serviceExists) {
99
+ // Service exists, start it directly
100
+ await startExistingService(serviceName, platformInfo);
101
+ return { service: serviceName, status: 'success', error: null };
102
+ } else {
103
+ // Service doesn't exist, look for file
104
+ const serviceFile = findServiceFile(serviceName);
105
+ if (!serviceFile) {
106
+ throw new Error(`Service file not found for: ${serviceName}`);
107
+ }
108
+
109
+ await handleSingleServiceStart(serviceFile, { ...options, name: serviceName });
110
+ return { service: serviceName, status: 'success', error: null };
111
+ }
101
112
  } catch (error) {
102
- return { service: serviceName, status: 'failed', error: error instanceof Error ? error.message : String(error) };
113
+ return { service: serviceName, status: 'failed', error: (error as Error).message };
103
114
  }
104
115
  })
105
116
  );
@@ -47,16 +47,20 @@ export async function parseServiceArray(input: string): Promise<string[]> {
47
47
 
48
48
  export async function getAllServices(): Promise<string[]> {
49
49
  try {
50
- const output = execSync("systemctl --user list-units --type=service --all --no-pager --no-legend", {
51
- encoding: "utf-8"
52
- });
50
+ // Use the same logic as the status command since it already works
51
+ const output = execSync("systemctl --user list-units --type=service --all --no-pager --no-legend", { encoding: "utf-8" });
52
+ const lines = output.split("\n").filter(line => line.includes(".service"));
53
53
 
54
- const services = output
55
- .split('\n')
56
- .filter(line => line.trim())
57
- .map(line => line.split(' ')[0])
58
- .filter(service => service.includes('bs9-'))
59
- .map(service => service.replace('bs9-', ''));
54
+ const services = [];
55
+ for (const line of lines) {
56
+ const match = line.match(/^(?:\s*([●\s○]))?\s*([^\s]+)\.service\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+(.+)$/);
57
+ if (match) {
58
+ const [, , name, , , , description] = match;
59
+ if (description.includes("BS9 Service:")) {
60
+ services.push(name);
61
+ }
62
+ }
63
+ }
60
64
 
61
65
  return services;
62
66
  } catch {
@@ -67,7 +71,9 @@ export async function getAllServices(): Promise<string[]> {
67
71
  export async function getServicesByPattern(pattern: string): Promise<string[]> {
68
72
  try {
69
73
  const allServices = await getAllServices();
70
- const regex = new RegExp(`^${pattern}$`);
74
+ // Convert glob pattern to regex
75
+ const regexPattern = pattern.replace(/\*/g, '.*');
76
+ const regex = new RegExp(`^${regexPattern}$`);
71
77
  return allServices.filter(service => regex.test(service));
72
78
  } catch {
73
79
  return [];