xray-manager 1.0.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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +798 -0
  3. package/dist/cli.d.ts +11 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +113 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/config.d.ts +49 -0
  8. package/dist/commands/config.d.ts.map +1 -0
  9. package/dist/commands/config.js +295 -0
  10. package/dist/commands/config.js.map +1 -0
  11. package/dist/commands/interactive.d.ts +83 -0
  12. package/dist/commands/interactive.d.ts.map +1 -0
  13. package/dist/commands/interactive.js +362 -0
  14. package/dist/commands/interactive.js.map +1 -0
  15. package/dist/commands/logs.d.ts +43 -0
  16. package/dist/commands/logs.d.ts.map +1 -0
  17. package/dist/commands/logs.js +257 -0
  18. package/dist/commands/logs.js.map +1 -0
  19. package/dist/commands/service.d.ts +43 -0
  20. package/dist/commands/service.d.ts.map +1 -0
  21. package/dist/commands/service.js +177 -0
  22. package/dist/commands/service.js.map +1 -0
  23. package/dist/commands/user.d.ts +43 -0
  24. package/dist/commands/user.d.ts.map +1 -0
  25. package/dist/commands/user.js +212 -0
  26. package/dist/commands/user.js.map +1 -0
  27. package/dist/constants/exit-codes.d.ts +49 -0
  28. package/dist/constants/exit-codes.d.ts.map +1 -0
  29. package/dist/constants/exit-codes.js +100 -0
  30. package/dist/constants/exit-codes.js.map +1 -0
  31. package/dist/constants/paths.d.ts +57 -0
  32. package/dist/constants/paths.d.ts.map +1 -0
  33. package/dist/constants/paths.js +72 -0
  34. package/dist/constants/paths.js.map +1 -0
  35. package/dist/constants/timeouts.d.ts +84 -0
  36. package/dist/constants/timeouts.d.ts.map +1 -0
  37. package/dist/constants/timeouts.js +111 -0
  38. package/dist/constants/timeouts.js.map +1 -0
  39. package/dist/services/config-manager.d.ts +66 -0
  40. package/dist/services/config-manager.d.ts.map +1 -0
  41. package/dist/services/config-manager.js +206 -0
  42. package/dist/services/config-manager.js.map +1 -0
  43. package/dist/services/log-manager.d.ts +113 -0
  44. package/dist/services/log-manager.d.ts.map +1 -0
  45. package/dist/services/log-manager.js +288 -0
  46. package/dist/services/log-manager.js.map +1 -0
  47. package/dist/services/systemd-manager.d.ts +197 -0
  48. package/dist/services/systemd-manager.d.ts.map +1 -0
  49. package/dist/services/systemd-manager.js +458 -0
  50. package/dist/services/systemd-manager.js.map +1 -0
  51. package/dist/services/user-manager.d.ts +63 -0
  52. package/dist/services/user-manager.d.ts.map +1 -0
  53. package/dist/services/user-manager.js +219 -0
  54. package/dist/services/user-manager.js.map +1 -0
  55. package/dist/types/config.d.ts +256 -0
  56. package/dist/types/config.d.ts.map +1 -0
  57. package/dist/types/config.js +7 -0
  58. package/dist/types/config.js.map +1 -0
  59. package/dist/types/service.d.ts +96 -0
  60. package/dist/types/service.d.ts.map +1 -0
  61. package/dist/types/service.js +7 -0
  62. package/dist/types/service.js.map +1 -0
  63. package/dist/types/user.d.ts +114 -0
  64. package/dist/types/user.d.ts.map +1 -0
  65. package/dist/types/user.js +7 -0
  66. package/dist/types/user.js.map +1 -0
  67. package/dist/utils/clipboard.d.ts +21 -0
  68. package/dist/utils/clipboard.d.ts.map +1 -0
  69. package/dist/utils/clipboard.js +45 -0
  70. package/dist/utils/clipboard.js.map +1 -0
  71. package/dist/utils/format.d.ts +93 -0
  72. package/dist/utils/format.d.ts.map +1 -0
  73. package/dist/utils/format.js +242 -0
  74. package/dist/utils/format.js.map +1 -0
  75. package/dist/utils/logger.d.ts +113 -0
  76. package/dist/utils/logger.d.ts.map +1 -0
  77. package/dist/utils/logger.js +260 -0
  78. package/dist/utils/logger.js.map +1 -0
  79. package/dist/utils/preflight.d.ts +57 -0
  80. package/dist/utils/preflight.d.ts.map +1 -0
  81. package/dist/utils/preflight.js +215 -0
  82. package/dist/utils/preflight.js.map +1 -0
  83. package/dist/utils/validator.d.ts +102 -0
  84. package/dist/utils/validator.d.ts.map +1 -0
  85. package/dist/utils/validator.js +238 -0
  86. package/dist/utils/validator.js.map +1 -0
  87. package/dist/utils/which.d.ts +13 -0
  88. package/dist/utils/which.d.ts.map +1 -0
  89. package/dist/utils/which.js +28 -0
  90. package/dist/utils/which.js.map +1 -0
  91. package/package.json +69 -0
@@ -0,0 +1,197 @@
1
+ /**
2
+ * SystemdManager - Service Management via systemctl
3
+ *
4
+ * Provides safe interface to systemd service management with:
5
+ * - Command injection prevention
6
+ * - Action and service name validation
7
+ * - Graceful shutdown with configurable timeout
8
+ * - Detailed status parsing
9
+ *
10
+ * @module services/systemd-manager
11
+ */
12
+ /**
13
+ * Service status information
14
+ */
15
+ export interface ServiceStatus {
16
+ /** Service name */
17
+ serviceName: string;
18
+ /** Whether service is active */
19
+ active: boolean;
20
+ /** Active state (active, inactive, failed, etc.) */
21
+ activeState: string;
22
+ /** Sub state (running, dead, failed, etc.) */
23
+ subState: string;
24
+ /** Whether service is loaded */
25
+ loaded: boolean;
26
+ /** Whether service is healthy */
27
+ healthy: boolean;
28
+ /** Main process PID (null if not running) */
29
+ pid: number | null;
30
+ /** Memory usage (formatted string) */
31
+ memory?: string;
32
+ /** Number of restarts */
33
+ restarts?: number;
34
+ /** Uptime (formatted string) */
35
+ uptime?: string;
36
+ /** Start timestamp */
37
+ startTime?: Date;
38
+ }
39
+ /**
40
+ * Service operation result
41
+ */
42
+ export interface ServiceOperationResult {
43
+ /** Whether operation succeeded */
44
+ success: boolean;
45
+ /** Operation type */
46
+ operation: string;
47
+ /** Service name */
48
+ serviceName: string;
49
+ /** Exit code */
50
+ exitCode: number;
51
+ /** Duration in milliseconds */
52
+ duration: number;
53
+ /** Downtime in milliseconds (for restart) */
54
+ downtime?: number;
55
+ /** Standard output */
56
+ stdout?: string;
57
+ /** Standard error */
58
+ stderr?: string;
59
+ }
60
+ /**
61
+ * Systemctl execution options
62
+ */
63
+ export interface SystemctlOptions {
64
+ /** Timeout in milliseconds */
65
+ timeout?: number;
66
+ }
67
+ /**
68
+ * Restart options
69
+ */
70
+ export interface RestartOptions {
71
+ /** Graceful shutdown timeout in milliseconds */
72
+ gracefulTimeout?: number;
73
+ /** Whether to wait for active connections to complete */
74
+ waitForConnections?: boolean;
75
+ }
76
+ /**
77
+ * SystemdManager - Safe systemctl wrapper
78
+ */
79
+ export declare class SystemdManager {
80
+ private serviceName;
81
+ /** Valid systemctl actions (whitelist) */
82
+ private static readonly VALID_ACTIONS;
83
+ /**
84
+ * Create a new SystemdManager
85
+ *
86
+ * @param serviceName - Service name to manage
87
+ * @throws Error if service name is invalid
88
+ */
89
+ constructor(serviceName: string);
90
+ /**
91
+ * Validate service name
92
+ *
93
+ * @param name - Service name to validate
94
+ * @throws Error if service name is invalid
95
+ */
96
+ private validateServiceName;
97
+ /**
98
+ * Validate systemctl action
99
+ *
100
+ * @param action - Action to validate
101
+ * @throws Error if action is invalid
102
+ */
103
+ validateAction(action: string): void;
104
+ /**
105
+ * Execute systemctl command
106
+ *
107
+ * @param action - Systemctl action to execute
108
+ * @param options - Execution options
109
+ * @returns Command output
110
+ */
111
+ executeSystemctl(action: string, options?: SystemctlOptions): Promise<string>;
112
+ /**
113
+ * Parse systemd error messages and provide suggestions
114
+ *
115
+ * @param errorOutput - Error output from systemctl
116
+ * @param action - Action that was attempted
117
+ * @returns User-friendly error message with suggestions
118
+ */
119
+ private parseSystemdError;
120
+ /**
121
+ * Parse systemctl show output
122
+ *
123
+ * @param output - Raw output from systemctl show
124
+ * @returns Parsed service status
125
+ */
126
+ parseSystemdShow(output: string): ServiceStatus;
127
+ /**
128
+ * Format bytes to human-readable string
129
+ *
130
+ * @param bytes - Number of bytes
131
+ * @returns Formatted string (e.g., "45.2 MB")
132
+ */
133
+ private formatBytes;
134
+ /**
135
+ * Format uptime in milliseconds to human-readable string
136
+ *
137
+ * @param ms - Uptime in milliseconds
138
+ * @returns Formatted string (e.g., "2小时15分钟")
139
+ */
140
+ private formatUptime;
141
+ /**
142
+ * Get service status
143
+ *
144
+ * @returns Service status information
145
+ */
146
+ getStatus(): Promise<ServiceStatus>;
147
+ /**
148
+ * Start service
149
+ *
150
+ * @returns Operation result
151
+ */
152
+ start(): Promise<ServiceOperationResult>;
153
+ /**
154
+ * Stop service
155
+ *
156
+ * @returns Operation result
157
+ */
158
+ stop(): Promise<ServiceOperationResult>;
159
+ /**
160
+ * Restart service with graceful shutdown
161
+ *
162
+ * @param options - Restart options
163
+ * @returns Operation result
164
+ */
165
+ restart(options?: RestartOptions): Promise<ServiceOperationResult>;
166
+ /**
167
+ * Wait for service to be ready after start/restart
168
+ *
169
+ * @param maxWait - Maximum time to wait in milliseconds
170
+ */
171
+ private waitForServiceReady;
172
+ /**
173
+ * Check if running as root
174
+ *
175
+ * @returns True if running as root
176
+ */
177
+ isRoot(): boolean;
178
+ /**
179
+ * Check if sudo is available
180
+ *
181
+ * @returns True if sudo is available
182
+ */
183
+ canUseSudo(): Promise<boolean>;
184
+ /**
185
+ * Get permission warning message
186
+ *
187
+ * @returns Warning message if not running with sufficient permissions
188
+ */
189
+ getPermissionWarning(): string | undefined;
190
+ /**
191
+ * Estimate downtime for restart operation
192
+ *
193
+ * @returns Estimated downtime in milliseconds
194
+ */
195
+ estimateDowntime(): number;
196
+ }
197
+ //# sourceMappingURL=systemd-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemd-manager.d.ts","sourceRoot":"","sources":["../../src/services/systemd-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IAEpB,gCAAgC;IAChC,MAAM,EAAE,OAAO,CAAC;IAEhB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IAEpB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IAEjB,gCAAgC;IAChC,MAAM,EAAE,OAAO,CAAC;IAEhB,iCAAiC;IACjC,OAAO,EAAE,OAAO,C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I;IAgBpC;;;;;;OAMG;IACG,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAsCnF;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IA6CzB;;;;;OAKG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IA4E/C;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAWnB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAiBpB;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;IAKzC;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAgC9C;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAgC7C;;;;;OAKG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA2CxE;;;;OAIG;YACW,mBAAmB;IAsBjC;;;;OAIG;IACH,MAAM,IAAI,OAAO;IAIjB;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAcpC;;;;OAIG;IACH,oBAAoB,IAAI,MAAM,GAAG,SAAS;IAQ1C;;;;OAIG;IACH,gBAAgB,IAAI,MAAM;CAK3B"}
@@ -0,0 +1,458 @@
1
+ "use strict";
2
+ /**
3
+ * SystemdManager - Service Management via systemctl
4
+ *
5
+ * Provides safe interface to systemd service management with:
6
+ * - Command injection prevention
7
+ * - Action and service name validation
8
+ * - Graceful shutdown with configurable timeout
9
+ * - Detailed status parsing
10
+ *
11
+ * @module services/systemd-manager
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.SystemdManager = void 0;
15
+ const child_process_1 = require("child_process");
16
+ const timeouts_1 = require("../constants/timeouts");
17
+ /**
18
+ * SystemdManager - Safe systemctl wrapper
19
+ */
20
+ class SystemdManager {
21
+ /**
22
+ * Create a new SystemdManager
23
+ *
24
+ * @param serviceName - Service name to manage
25
+ * @throws Error if service name is invalid
26
+ */
27
+ constructor(serviceName) {
28
+ this.validateServiceName(serviceName);
29
+ this.serviceName = serviceName;
30
+ }
31
+ /**
32
+ * Validate service name
33
+ *
34
+ * @param name - Service name to validate
35
+ * @throws Error if service name is invalid
36
+ */
37
+ validateServiceName(name) {
38
+ // Prevent empty names
39
+ if (!name || name.trim().length === 0) {
40
+ throw new Error('Service name cannot be empty');
41
+ }
42
+ // Prevent path traversal attempts
43
+ if (name.includes('/') || name.includes('\\') || name.includes('..')) {
44
+ throw new Error(`Invalid service name: ${name} (path traversal detected)`);
45
+ }
46
+ // Prevent command injection attempts
47
+ const dangerousChars = /[;&|`$()]/;
48
+ if (dangerousChars.test(name)) {
49
+ throw new Error(`Invalid service name: ${name} (potentially dangerous characters detected)`);
50
+ }
51
+ // Only allow alphanumeric, dash, underscore
52
+ const validPattern = /^[a-zA-Z0-9_-]+$/;
53
+ if (!validPattern.test(name)) {
54
+ throw new Error(`Invalid service name: ${name} (only alphanumeric, dash, and underscore allowed)`);
55
+ }
56
+ }
57
+ /**
58
+ * Validate systemctl action
59
+ *
60
+ * @param action - Action to validate
61
+ * @throws Error if action is invalid
62
+ */
63
+ validateAction(action) {
64
+ if (!SystemdManager.VALID_ACTIONS.includes(action)) {
65
+ throw new Error(`Invalid systemctl action: ${action} (must be one of: ${SystemdManager.VALID_ACTIONS.join(', ')})`);
66
+ }
67
+ // Extra paranoia: check for command injection attempts
68
+ const dangerousChars = /[;&|`$()]/;
69
+ if (dangerousChars.test(action)) {
70
+ throw new Error(`Invalid systemctl action: ${action} (potentially dangerous characters detected)`);
71
+ }
72
+ }
73
+ /**
74
+ * Execute systemctl command
75
+ *
76
+ * @param action - Systemctl action to execute
77
+ * @param options - Execution options
78
+ * @returns Command output
79
+ */
80
+ async executeSystemctl(action, options) {
81
+ // Validate action to prevent command injection
82
+ this.validateAction(action);
83
+ const timeout = options?.timeout || timeouts_1.TIMEOUTS.SYSTEMCTL_DEFAULT;
84
+ return new Promise((resolve, reject) => {
85
+ // Use spawn (not exec) to prevent shell injection
86
+ const child = (0, child_process_1.spawn)('systemctl', [action, this.serviceName], {
87
+ timeout,
88
+ });
89
+ let stdout = '';
90
+ let stderr = '';
91
+ child.stdout?.on('data', (data) => {
92
+ stdout += data.toString();
93
+ });
94
+ child.stderr?.on('data', (data) => {
95
+ stderr += data.toString();
96
+ });
97
+ child.on('close', (code) => {
98
+ if (code === 0) {
99
+ resolve(stdout);
100
+ }
101
+ else {
102
+ const errorMessage = this.parseSystemdError(stderr || stdout, action);
103
+ reject(new Error(errorMessage));
104
+ }
105
+ });
106
+ child.on('error', (error) => {
107
+ reject(new Error(`Failed to execute systemctl: ${error.message}`));
108
+ });
109
+ });
110
+ }
111
+ /**
112
+ * Parse systemd error messages and provide suggestions
113
+ *
114
+ * @param errorOutput - Error output from systemctl
115
+ * @param action - Action that was attempted
116
+ * @returns User-friendly error message with suggestions
117
+ */
118
+ parseSystemdError(errorOutput, action) {
119
+ const lowerError = errorOutput.toLowerCase();
120
+ // Service not found
121
+ if (lowerError.includes('not found') ||
122
+ lowerError.includes('does not exist') ||
123
+ lowerError.includes('could not be found')) {
124
+ return `服务 '${this.serviceName}' 不存在。请确认服务名称是否正确。`;
125
+ }
126
+ // Permission denied
127
+ if (lowerError.includes('permission denied') ||
128
+ lowerError.includes('access denied') ||
129
+ lowerError.includes('authentication required')) {
130
+ return `权限不足: 无法执行 ${action} 操作。请使用 sudo 或以 root 用户运行。`;
131
+ }
132
+ // Timeout
133
+ if (lowerError.includes('timeout') || lowerError.includes('timed out')) {
134
+ return `操作超时: ${action} 操作未能在规定时间内完成。`;
135
+ }
136
+ // Already running/stopped
137
+ if (action === 'start' &&
138
+ (lowerError.includes('already running') || lowerError.includes('already active'))) {
139
+ return `服务 '${this.serviceName}' 已经在运行中。`;
140
+ }
141
+ if (action === 'stop' &&
142
+ (lowerError.includes('already stopped') || lowerError.includes('inactive'))) {
143
+ return `服务 '${this.serviceName}' 已经停止。`;
144
+ }
145
+ // Generic error with original output
146
+ return `执行 systemctl ${action} 失败: ${errorOutput}`;
147
+ }
148
+ /**
149
+ * Parse systemctl show output
150
+ *
151
+ * @param output - Raw output from systemctl show
152
+ * @returns Parsed service status
153
+ */
154
+ parseSystemdShow(output) {
155
+ const lines = output.split('\n');
156
+ const props = {};
157
+ // Parse key=value pairs
158
+ for (const line of lines) {
159
+ const trimmed = line.trim();
160
+ if (!trimmed || !trimmed.includes('=')) {
161
+ continue;
162
+ }
163
+ const [key, ...valueParts] = trimmed.split('=');
164
+ const value = valueParts.join('='); // Handle values with '=' in them
165
+ props[key] = value;
166
+ }
167
+ // Validate we have at least basic properties
168
+ if (!props.ActiveState && !props.SubState) {
169
+ throw new Error('Invalid systemctl show output: missing required fields (parse error)');
170
+ }
171
+ // Parse active state
172
+ const activeState = props.ActiveState || 'unknown';
173
+ const subState = props.SubState || 'unknown';
174
+ const active = activeState === 'active';
175
+ // Parse loaded state
176
+ const loaded = props.LoadState === 'loaded';
177
+ // Parse PID
178
+ const pidStr = props.MainPID || '0';
179
+ const pid = parseInt(pidStr, 10);
180
+ const pidValue = pid > 0 ? pid : null;
181
+ // Parse memory usage
182
+ const memoryBytes = parseInt(props.MemoryCurrent || '0', 10);
183
+ const memory = this.formatBytes(memoryBytes);
184
+ // Parse restart count
185
+ const restarts = parseInt(props.NRestarts || '0', 10);
186
+ // Parse start time and calculate uptime
187
+ const startTimestamp = props.ExecMainStartTimestamp;
188
+ let uptime;
189
+ let startTime;
190
+ if (startTimestamp && startTimestamp.trim() !== '') {
191
+ try {
192
+ startTime = new Date(startTimestamp);
193
+ const now = Date.now();
194
+ const startMs = startTime.getTime();
195
+ const uptimeMs = now - startMs;
196
+ uptime = this.formatUptime(uptimeMs);
197
+ }
198
+ catch {
199
+ // Ignore parse errors
200
+ }
201
+ }
202
+ // Determine health
203
+ const healthy = active && subState === 'running';
204
+ return {
205
+ serviceName: this.serviceName,
206
+ active,
207
+ activeState,
208
+ subState,
209
+ loaded,
210
+ healthy,
211
+ pid: pidValue,
212
+ memory,
213
+ restarts,
214
+ uptime,
215
+ startTime,
216
+ };
217
+ }
218
+ /**
219
+ * Format bytes to human-readable string
220
+ *
221
+ * @param bytes - Number of bytes
222
+ * @returns Formatted string (e.g., "45.2 MB")
223
+ */
224
+ formatBytes(bytes) {
225
+ if (bytes === 0)
226
+ return '0 B';
227
+ const units = ['B', 'KB', 'MB', 'GB'];
228
+ const k = 1024;
229
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
230
+ const value = bytes / Math.pow(k, i);
231
+ return `${value.toFixed(1)} ${units[i]}`;
232
+ }
233
+ /**
234
+ * Format uptime in milliseconds to human-readable string
235
+ *
236
+ * @param ms - Uptime in milliseconds
237
+ * @returns Formatted string (e.g., "2小时15分钟")
238
+ */
239
+ formatUptime(ms) {
240
+ const seconds = Math.floor(ms / 1000);
241
+ const minutes = Math.floor(seconds / 60);
242
+ const hours = Math.floor(minutes / 60);
243
+ const days = Math.floor(hours / 24);
244
+ if (days > 0) {
245
+ return `${days}天${hours % 24}小时`;
246
+ }
247
+ else if (hours > 0) {
248
+ return `${hours}小时${minutes % 60}分钟`;
249
+ }
250
+ else if (minutes > 0) {
251
+ return `${minutes}分钟`;
252
+ }
253
+ else {
254
+ return `${seconds}秒`;
255
+ }
256
+ }
257
+ /**
258
+ * Get service status
259
+ *
260
+ * @returns Service status information
261
+ */
262
+ async getStatus() {
263
+ const output = await this.executeSystemctl('show');
264
+ return this.parseSystemdShow(output);
265
+ }
266
+ /**
267
+ * Start service
268
+ *
269
+ * @returns Operation result
270
+ */
271
+ async start() {
272
+ const startTime = Date.now();
273
+ try {
274
+ const stdout = await this.executeSystemctl('start', {
275
+ timeout: timeouts_1.TIMEOUTS.SERVICE_START,
276
+ });
277
+ const duration = Date.now() - startTime;
278
+ return {
279
+ success: true,
280
+ operation: 'start',
281
+ serviceName: this.serviceName,
282
+ exitCode: 0,
283
+ duration,
284
+ stdout,
285
+ };
286
+ }
287
+ catch (error) {
288
+ const duration = Date.now() - startTime;
289
+ return {
290
+ success: false,
291
+ operation: 'start',
292
+ serviceName: this.serviceName,
293
+ exitCode: 1,
294
+ duration,
295
+ stderr: error.message,
296
+ };
297
+ }
298
+ }
299
+ /**
300
+ * Stop service
301
+ *
302
+ * @returns Operation result
303
+ */
304
+ async stop() {
305
+ const startTime = Date.now();
306
+ try {
307
+ const stdout = await this.executeSystemctl('stop', {
308
+ timeout: timeouts_1.TIMEOUTS.SERVICE_STOP,
309
+ });
310
+ const duration = Date.now() - startTime;
311
+ return {
312
+ success: true,
313
+ operation: 'stop',
314
+ serviceName: this.serviceName,
315
+ exitCode: 0,
316
+ duration,
317
+ stdout,
318
+ };
319
+ }
320
+ catch (error) {
321
+ const duration = Date.now() - startTime;
322
+ return {
323
+ success: false,
324
+ operation: 'stop',
325
+ serviceName: this.serviceName,
326
+ exitCode: 1,
327
+ duration,
328
+ stderr: error.message,
329
+ };
330
+ }
331
+ }
332
+ /**
333
+ * Restart service with graceful shutdown
334
+ *
335
+ * @param options - Restart options
336
+ * @returns Operation result
337
+ */
338
+ async restart(options) {
339
+ const gracefulTimeout = options?.gracefulTimeout || 10000; // Default 10s (FR-016)
340
+ const restartStartTime = Date.now();
341
+ try {
342
+ // Measure service downtime
343
+ const downtimeStart = Date.now();
344
+ // Use systemctl restart which handles graceful shutdown internally
345
+ const stdout = await this.executeSystemctl('restart', {
346
+ timeout: timeouts_1.TIMEOUTS.SERVICE_RESTART,
347
+ });
348
+ // Wait a moment for service to fully start
349
+ await this.waitForServiceReady(gracefulTimeout);
350
+ const downtimeEnd = Date.now();
351
+ const downtime = downtimeEnd - downtimeStart;
352
+ const duration = Date.now() - restartStartTime;
353
+ return {
354
+ success: true,
355
+ operation: 'restart',
356
+ serviceName: this.serviceName,
357
+ exitCode: 0,
358
+ duration,
359
+ downtime,
360
+ stdout,
361
+ };
362
+ }
363
+ catch (error) {
364
+ const duration = Date.now() - restartStartTime;
365
+ return {
366
+ success: false,
367
+ operation: 'restart',
368
+ serviceName: this.serviceName,
369
+ exitCode: 1,
370
+ duration,
371
+ stderr: error.message,
372
+ };
373
+ }
374
+ }
375
+ /**
376
+ * Wait for service to be ready after start/restart
377
+ *
378
+ * @param maxWait - Maximum time to wait in milliseconds
379
+ */
380
+ async waitForServiceReady(maxWait) {
381
+ const startTime = Date.now();
382
+ const pollInterval = 100; // Check every 100ms
383
+ while (Date.now() - startTime < maxWait) {
384
+ try {
385
+ const status = await this.getStatus();
386
+ if (status.active && status.subState === 'running') {
387
+ return; // Service is ready
388
+ }
389
+ }
390
+ catch {
391
+ // Ignore errors during polling
392
+ }
393
+ // Wait before next poll
394
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
395
+ }
396
+ // If we get here, service didn't become ready in time
397
+ // But don't throw - let caller determine if this is critical
398
+ }
399
+ /**
400
+ * Check if running as root
401
+ *
402
+ * @returns True if running as root
403
+ */
404
+ isRoot() {
405
+ return !!(process.getuid && process.getuid() === 0);
406
+ }
407
+ /**
408
+ * Check if sudo is available
409
+ *
410
+ * @returns True if sudo is available
411
+ */
412
+ async canUseSudo() {
413
+ return new Promise((resolve) => {
414
+ const child = (0, child_process_1.spawn)('which', ['sudo']);
415
+ child.on('close', (code) => {
416
+ resolve(code === 0);
417
+ });
418
+ child.on('error', () => {
419
+ resolve(false);
420
+ });
421
+ });
422
+ }
423
+ /**
424
+ * Get permission warning message
425
+ *
426
+ * @returns Warning message if not running with sufficient permissions
427
+ */
428
+ getPermissionWarning() {
429
+ if (this.isRoot()) {
430
+ return undefined;
431
+ }
432
+ return '当前用户不是 root - 某些操作可能需要 sudo 权限';
433
+ }
434
+ /**
435
+ * Estimate downtime for restart operation
436
+ *
437
+ * @returns Estimated downtime in milliseconds
438
+ */
439
+ estimateDowntime() {
440
+ // Estimate based on typical graceful shutdown time
441
+ // Conservative estimate: 5 seconds
442
+ return 5000;
443
+ }
444
+ }
445
+ exports.SystemdManager = SystemdManager;
446
+ /** Valid systemctl actions (whitelist) */
447
+ SystemdManager.VALID_ACTIONS = [
448
+ 'start',
449
+ 'stop',
450
+ 'restart',
451
+ 'status',
452
+ 'enable',
453
+ 'disable',
454
+ 'is-active',
455
+ 'is-enabled',
456
+ 'show',
457
+ ];
458
+ //# sourceMappingURL=systemd-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemd-manager.js","sourceRoot":"","sources":["../../src/services/systemd-manager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,iDAAsC;AACtC,oDAAiD;AAwFjD;;GAEG;AACH,MAAa,cAAc;IAgBzB;;;;;OAKG;IACH,YAAY,WAAmB;QAC7B,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACK,mBAAmB,CAAC,IAAY;QACtC,sBAAsB;QACtB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QAED,kCAAkC;QAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,4BAA4B,CAAC,CAAC;QAC7E,CAAC;QAED,qCAAqC;QACrC,MAAM,cAAc,GAAG,WAAW,CAAC;QACnC,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,8CAA8C,CAAC,CAAC;QAC/F,CAAC;QAED,4CAA4C;QAC5C,MAAM,YAAY,GAAG,kBAAkB,CAAC;QACxC,I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