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 +1 -1
- package/src/commands/start.ts +19 -8
- package/src/utils/array-parser.ts +16 -10
package/package.json
CHANGED
package/src/commands/start.ts
CHANGED
|
@@ -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
|
-
|
|
94
|
-
|
|
95
|
-
if
|
|
96
|
-
|
|
97
|
-
}
|
|
93
|
+
const platformInfo = getPlatformInfo();
|
|
94
|
+
|
|
95
|
+
// First check if service already exists
|
|
96
|
+
const serviceExists = await checkServiceExists(serviceName, platformInfo);
|
|
98
97
|
|
|
99
|
-
|
|
100
|
-
|
|
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
|
|
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
|
-
|
|
51
|
-
|
|
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 =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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 [];
|