@dsh-sup/dsh-core-linux-x64 0.1.5-BETA.5 → 0.1.5-BETA.6
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/core.cjs +107 -106
- package/package.json +1 -1
package/core.cjs
CHANGED
|
@@ -80,6 +80,71 @@ var require_exec = __commonJS({
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
+
// src/platform/state-root.js
|
|
84
|
+
var require_state_root = __commonJS({
|
|
85
|
+
"src/platform/state-root.js"(exports2, module2) {
|
|
86
|
+
"use strict";
|
|
87
|
+
var fs2 = require("node:fs");
|
|
88
|
+
var os2 = require("node:os");
|
|
89
|
+
var path2 = require("node:path");
|
|
90
|
+
var SCHEMA = 1;
|
|
91
|
+
function root() {
|
|
92
|
+
const override = process.env.DSH_SUPERVISOR_HOME;
|
|
93
|
+
if (override && String(override).trim()) return path2.resolve(String(override).trim());
|
|
94
|
+
if (process.platform === "win32") {
|
|
95
|
+
const local = process.env.LOCALAPPDATA || path2.join(os2.homedir(), "AppData", "Local");
|
|
96
|
+
return path2.join(local, "dsh-supervisor");
|
|
97
|
+
}
|
|
98
|
+
if (process.platform === "darwin") {
|
|
99
|
+
return path2.join(os2.homedir(), "Library", "Application Support", "dsh-supervisor");
|
|
100
|
+
}
|
|
101
|
+
const xdg = process.env.XDG_STATE_HOME;
|
|
102
|
+
return xdg && String(xdg).trim() ? path2.join(String(xdg).trim(), "dsh-supervisor") : path2.join(os2.homedir(), ".local", "state", "dsh-supervisor");
|
|
103
|
+
}
|
|
104
|
+
function supervisorDir() {
|
|
105
|
+
return path2.join(root(), "supervisor");
|
|
106
|
+
}
|
|
107
|
+
function shellDir() {
|
|
108
|
+
return path2.join(root(), "shell");
|
|
109
|
+
}
|
|
110
|
+
function legacySupervisorDir() {
|
|
111
|
+
return path2.join(os2.homedir(), ".dsh", "supervisor");
|
|
112
|
+
}
|
|
113
|
+
function legacyShellDir() {
|
|
114
|
+
return path2.join(os2.homedir(), ".dsh", "shell");
|
|
115
|
+
}
|
|
116
|
+
function migrateLegacy() {
|
|
117
|
+
const moved = [];
|
|
118
|
+
for (const [from, to] of [
|
|
119
|
+
[legacySupervisorDir(), supervisorDir()],
|
|
120
|
+
[legacyShellDir(), shellDir()]
|
|
121
|
+
]) {
|
|
122
|
+
try {
|
|
123
|
+
if (!fs2.existsSync(from)) continue;
|
|
124
|
+
fs2.mkdirSync(to, { recursive: true });
|
|
125
|
+
for (const name of fs2.readdirSync(from)) {
|
|
126
|
+
const src = path2.join(from, name);
|
|
127
|
+
const dst = path2.join(to, name);
|
|
128
|
+
if (fs2.existsSync(dst)) continue;
|
|
129
|
+
try {
|
|
130
|
+
fs2.renameSync(src, dst);
|
|
131
|
+
moved.push(src + " -> " + dst);
|
|
132
|
+
} catch {
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
if (fs2.readdirSync(from).length === 0) fs2.rmdirSync(from);
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return moved;
|
|
143
|
+
}
|
|
144
|
+
module2.exports = { SCHEMA, root, supervisorDir, shellDir, legacySupervisorDir, legacyShellDir, migrateLegacy };
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
83
148
|
// src/platform/config.js
|
|
84
149
|
var require_config = __commonJS({
|
|
85
150
|
"src/platform/config.js"(exports2, module2) {
|
|
@@ -92,6 +157,7 @@ var require_config = __commonJS({
|
|
|
92
157
|
if (p.startsWith("~/")) return path2.join(os2.homedir(), p.slice(2));
|
|
93
158
|
return p;
|
|
94
159
|
}
|
|
160
|
+
var SUP = require_state_root().supervisorDir();
|
|
95
161
|
var DEFAULTS = {
|
|
96
162
|
probeIntervalMs: 5e3,
|
|
97
163
|
// 健康探测(三层):L0 进程存活 + L1 端口监听 + L2 HTTP GET healthUrl。
|
|
@@ -117,15 +183,15 @@ var require_config = __commonJS({
|
|
|
117
183
|
// managed = relay/proxyInstance/oauthCallback 共享池(K8s 单一范围思想,杜绝段碎片化);
|
|
118
184
|
// providerApi = 智能路由供应商独立端点池(按供应商规模调大)。null = 用内置默认池。
|
|
119
185
|
portPools: null,
|
|
120
|
-
stateFile: "
|
|
186
|
+
stateFile: path2.join(SUP, "state.json"),
|
|
121
187
|
// 系统日志框架目录布局:log/ 与 events/ 分目录;
|
|
122
188
|
// 守卫(guard) 事件在 events/guard.events.log、分级日志在 log/guard.log(daemon 用 router/lan 同构文件)。
|
|
123
189
|
// 显式配置(既有生产 config.json / 测试)仍尊重用户给定路径——不强行改写。
|
|
124
|
-
logFile: "
|
|
190
|
+
logFile: path2.join(SUP, "events", "guard.events.log"),
|
|
125
191
|
eventsMaxBytes: 5 * 1024 * 1024,
|
|
126
|
-
supervisorLogFile: "
|
|
127
|
-
dshLogFile: "
|
|
128
|
-
upgradeLogFile: "
|
|
192
|
+
supervisorLogFile: path2.join(SUP, "log", "guard.log"),
|
|
193
|
+
dshLogFile: path2.join(SUP, "log", "dsh.log"),
|
|
194
|
+
upgradeLogFile: path2.join(SUP, "log", "upgrade.log"),
|
|
129
195
|
logLevel: "info",
|
|
130
196
|
logMaxBytes: 5 * 1024 * 1024,
|
|
131
197
|
notifyEnabled: true,
|
|
@@ -223,7 +289,7 @@ var require_version = __commonJS({
|
|
|
223
289
|
var fs2 = require("node:fs");
|
|
224
290
|
var path2 = require("node:path");
|
|
225
291
|
function guardVersion() {
|
|
226
|
-
if (true) return String("0.1.5-BETA.
|
|
292
|
+
if (true) return String("0.1.5-BETA.6");
|
|
227
293
|
try {
|
|
228
294
|
return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
|
|
229
295
|
} catch {
|
|
@@ -1551,7 +1617,7 @@ var require_autostart = __commonJS({
|
|
|
1551
1617
|
return String(s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1552
1618
|
}
|
|
1553
1619
|
function macGuiPlist(guiExe) {
|
|
1554
|
-
const log = path2.join(
|
|
1620
|
+
const log = path2.join(require_state_root().shellDir(), "gui-stdio.log");
|
|
1555
1621
|
return '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0"><dict>\n <key>Label</key><string>' + xmlEscape(GUI_LABEL) + "</string>\n <key>ProgramArguments</key>\n <array><string>" + xmlEscape(guiExe) + "</string></array>\n <key>RunAtLoad</key><true/>\n <key>LimitLoadToSessionType</key><string>Aqua</string>\n <key>ProcessType</key><string>Interactive</string>\n <key>StandardOutPath</key><string>" + xmlEscape(log) + "</string>\n <key>StandardErrorPath</key><string>" + xmlEscape(log) + "</string>\n</dict></plist>\n";
|
|
1556
1622
|
}
|
|
1557
1623
|
function guiFile() {
|
|
@@ -1605,54 +1671,14 @@ var require_autostart = __commonJS({
|
|
|
1605
1671
|
const errors = [];
|
|
1606
1672
|
if (isWindows) {
|
|
1607
1673
|
try {
|
|
1608
|
-
const watchdogPs1 = path2.join(os2.homedir(), ".dsh", "supervisor", "watchdog.ps1");
|
|
1609
1674
|
if (on) {
|
|
1610
|
-
const
|
|
1611
|
-
|
|
1612
|
-
const guiPath = guiCommand();
|
|
1613
|
-
const ps = [
|
|
1614
|
-
'$ErrorActionPreference = "SilentlyContinue"',
|
|
1615
|
-
"$port = " + JSON.stringify(String(apiPort)),
|
|
1616
|
-
"$daemon = " + JSON.stringify(String(daemon)),
|
|
1617
|
-
"$gui = " + JSON.stringify(String(guiPath)),
|
|
1618
|
-
"$up = Test-NetConnection -ComputerName 127.0.0.1 -Port $port -InformationLevel Quiet -WarningAction SilentlyContinue",
|
|
1619
|
-
"# \u2500\u2500 \u5B88\u536B\u4FDD\u6D3B\uFF08\u4EC5\u5728\u5B88\u536B\u4E0D\u53EF\u8FBE\u65F6\uFF09\u2500\u2500",
|
|
1620
|
-
"if (-not $up) {",
|
|
1621
|
-
" $p = @(Get-Process -Name dsh-supervisor -ErrorAction SilentlyContinue)",
|
|
1622
|
-
" if (-not $p) { Start-Process -FilePath $daemon -ArgumentList 'daemon' -WindowStyle Hidden }",
|
|
1623
|
-
"}",
|
|
1624
|
-
"# \u2500\u2500 \u58F3\u4FDD\u6D3B\uFF08\u26A0 \u5FC5\u987B**\u72EC\u7ACB\u4E8E\u5B88\u536B\u72B6\u6001**\uFF09\u2500\u2500",
|
|
1625
|
-
"# 2026-09-11 \u5BA1\u8BA1\u4FEE\u590D\uFF1A\u65E7\u5B9E\u73B0\u628A\u58F3\u68C0\u67E5\u5D4C\u5728\u4E0A\u9762\u7684 if (-not $up) \u5185\uFF0C",
|
|
1626
|
-
"# \u4E8E\u662F\u300C\u58F3\u5D29\u3001\u5B88\u536B\u6D3B\u300D\u65F6 $up \u4E3A\u771F \u2192 \u6574\u5757\u8DF3\u8FC7 \u2192 **\u58F3\u6C38\u8FDC\u4E0D\u4F1A\u88AB\u62C9\u8D77**\u3002",
|
|
1627
|
-
"# \u800C\u90A3\u6070\u662F\u58F3\u81EA\u6108\u552F\u4E00\u9700\u8981\u751F\u6548\u7684\u573A\u666F\uFF08\u5B88\u536B\u7531\u670D\u52A1\u7BA1\u7406\u5668\u4FDD\u6D3B\uFF0C\u58F3\u65E0\u4EBA\u7BA1\uFF09\u3002",
|
|
1628
|
-
"$g = @(Get-Process -Name dsh-supervisor-gui -ErrorAction SilentlyContinue)",
|
|
1629
|
-
"if (-not $g -and (Test-Path $gui)) { Start-Process -FilePath $gui -WindowStyle Hidden }",
|
|
1630
|
-
"exit 0"
|
|
1631
|
-
].join(String.fromCharCode(13, 10));
|
|
1632
|
-
fs2.mkdirSync(path2.dirname(watchdogPs1), { recursive: true });
|
|
1633
|
-
const atmp = watchdogPs1 + ".tmp";
|
|
1634
|
-
fs2.writeFileSync(atmp, ps);
|
|
1635
|
-
fs2.renameSync(atmp, watchdogPs1);
|
|
1636
|
-
{
|
|
1637
|
-
const r = ex2.runDetail("schtasks", ["/Create", "/TN", "DSH-Supervisor-GUI", "/SC", "ONLOGON", "/RL", "HIGHEST", "/F", "/TR", '"' + guiCommand() + '"']);
|
|
1638
|
-
if (!r.ok) errors.push("schtasks gui: " + (r.error || "\u6267\u884C\u5931\u8D25"));
|
|
1639
|
-
}
|
|
1640
|
-
ex2.run("schtasks", ["/Change", "/TN", "DSH-Supervisor", "/ENABLE"]);
|
|
1641
|
-
{
|
|
1642
|
-
const r = ex2.runDetail("schtasks", ["/Create", "/TN", "DSH-Supervisor-Watchdog", "/SC", "MINUTE", "/MO", "5", "/RL", "HIGHEST", "/F", "/TR", 'powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "' + watchdogPs1 + '"']);
|
|
1643
|
-
if (!r.ok) errors.push("schtasks watchdog: " + (r.error || "\u6267\u884C\u5931\u8D25"));
|
|
1644
|
-
}
|
|
1675
|
+
const r = ex2.runDetail("schtasks", ["/Create", "/TN", "DSH-Supervisor-GUI", "/SC", "ONLOGON", "/RL", "HIGHEST", "/F", "/TR", '"' + guiCommand() + '"']);
|
|
1676
|
+
if (!r.ok) errors.push("schtasks gui: " + (r.error || "\u6267\u884C\u5931\u8D25"));
|
|
1645
1677
|
} else {
|
|
1646
|
-
ex2.run("schtasks", ["/Delete", "/TN", "DSH-Supervisor-Watchdog", "/F"]);
|
|
1647
1678
|
ex2.run("schtasks", ["/Delete", "/TN", "DSH-Supervisor-GUI", "/F"]);
|
|
1648
|
-
ex2.run("schtasks", ["/Change", "/TN", "DSH-Supervisor", "/DISABLE"]);
|
|
1649
|
-
try {
|
|
1650
|
-
fs2.unlinkSync(watchdogPs1);
|
|
1651
|
-
} catch {
|
|
1652
|
-
}
|
|
1653
1679
|
}
|
|
1654
1680
|
} catch (e) {
|
|
1655
|
-
errors.push("
|
|
1681
|
+
errors.push("gui autostart: " + e.message);
|
|
1656
1682
|
}
|
|
1657
1683
|
return { ok: errors.length === 0, errors, ...status() };
|
|
1658
1684
|
}
|
|
@@ -1834,7 +1860,7 @@ var require_os = __commonJS({
|
|
|
1834
1860
|
return path2.join(os2.homedir(), ".dsh");
|
|
1835
1861
|
}
|
|
1836
1862
|
function supervisorDir() {
|
|
1837
|
-
return
|
|
1863
|
+
return require_state_root().supervisorDir();
|
|
1838
1864
|
}
|
|
1839
1865
|
function capabilityProfile(platform, arch) {
|
|
1840
1866
|
const pl = platform || PLATFORM;
|
|
@@ -2067,7 +2093,7 @@ var require_ports = __commonJS({
|
|
|
2067
2093
|
};
|
|
2068
2094
|
var PortRegistry = class {
|
|
2069
2095
|
constructor(opts) {
|
|
2070
|
-
this._file = opts && opts.file || path2.join(
|
|
2096
|
+
this._file = opts && opts.file || path2.join(require_state_root().supervisorDir(), "ports.json");
|
|
2071
2097
|
this._records = /* @__PURE__ */ new Map();
|
|
2072
2098
|
this._allocLock = false;
|
|
2073
2099
|
this._pools = Object.assign({}, DEFAULT_POOLS, opts && opts.pools || {});
|
|
@@ -3391,6 +3417,7 @@ var require_proxy = __commonJS({
|
|
|
3391
3417
|
this.kind = "proxy";
|
|
3392
3418
|
this.proxyAppId = opts.proxyAppId;
|
|
3393
3419
|
this.app = opts.app || null;
|
|
3420
|
+
this.stateDir = opts.stateDir || null;
|
|
3394
3421
|
this.proxyRunning = false;
|
|
3395
3422
|
this.instances = [];
|
|
3396
3423
|
this.selectedAccountKeyId = null;
|
|
@@ -3624,7 +3651,8 @@ var require_proxy = __commonJS({
|
|
|
3624
3651
|
const logFilter = /error|streaming|idle|timeout|ECONN|abort|socket|finish|truncat/i;
|
|
3625
3652
|
let logStream = null;
|
|
3626
3653
|
try {
|
|
3627
|
-
const
|
|
3654
|
+
const baseDir = this.stateDir || require("../../platform/state-root").supervisorDir();
|
|
3655
|
+
const logDir = require("node:path").join(baseDir, "logs");
|
|
3628
3656
|
require("node:fs").mkdirSync(logDir, { recursive: true });
|
|
3629
3657
|
logStream = require("node:fs").createWriteStream(require("node:path").join(logDir, "proxy-instance-" + this.proxyAppId + "-" + port + ".log"), { flags: "a" });
|
|
3630
3658
|
} catch {
|
|
@@ -4728,7 +4756,7 @@ var require_runtime_contract = __commonJS({
|
|
|
4728
4756
|
var path2 = require("node:path");
|
|
4729
4757
|
var SUPPORTED_SCHEMA = 2;
|
|
4730
4758
|
function file() {
|
|
4731
|
-
return path2.join(
|
|
4759
|
+
return path2.join(require_state_root().supervisorDir(), "runtime.json");
|
|
4732
4760
|
}
|
|
4733
4761
|
function read() {
|
|
4734
4762
|
let j;
|
|
@@ -6752,7 +6780,7 @@ var require_router = __commonJS({
|
|
|
6752
6780
|
}
|
|
6753
6781
|
}
|
|
6754
6782
|
_deserializeProvider(p) {
|
|
6755
|
-
const common = { id: p.id, name: p.name, logger: this.logger, events: this.events, dist: this.dist, onPersist: () => this._save(), apiPort: p.apiPort || null, activated: p.activated === true };
|
|
6783
|
+
const common = { id: p.id, name: p.name, logger: this.logger, events: this.events, dist: this.dist, onPersist: () => this._save(), stateDir: this.config && this.config.stateFile ? path2.dirname(this.config.stateFile) : null, apiPort: p.apiPort || null, activated: p.activated === true };
|
|
6756
6784
|
let prov;
|
|
6757
6785
|
if (p.kind === "proxy") {
|
|
6758
6786
|
prov = new ProxyProvider({ ...common, kind: "proxy", proxyAppId: p.proxyAppId, app: PROXY_APPS[p.proxyAppId] || null });
|
|
@@ -11763,7 +11791,7 @@ var require_shell = __commonJS({
|
|
|
11763
11791
|
var path2 = require("node:path");
|
|
11764
11792
|
var { semverCompare } = require_dist();
|
|
11765
11793
|
function shellDir() {
|
|
11766
|
-
return
|
|
11794
|
+
return require_state_root().shellDir();
|
|
11767
11795
|
}
|
|
11768
11796
|
function readJson(p) {
|
|
11769
11797
|
try {
|
|
@@ -19835,10 +19863,20 @@ var require_supervisor = __commonJS({
|
|
|
19835
19863
|
});
|
|
19836
19864
|
server.listen(port, this.config.apiHost, () => {
|
|
19837
19865
|
this.api = server;
|
|
19838
|
-
|
|
19866
|
+
const prev = this.config.apiPort;
|
|
19867
|
+
if (port !== prev) {
|
|
19868
|
+
try {
|
|
19869
|
+
ports.release(prev, "system:supervisor-api");
|
|
19870
|
+
} catch {
|
|
19871
|
+
}
|
|
19839
19872
|
this.config.apiPort = port;
|
|
19840
19873
|
if (this.configPath) this.persistConfigPatch({ apiPort: port });
|
|
19841
19874
|
}
|
|
19875
|
+
try {
|
|
19876
|
+
ports.register("supervisor-api", port);
|
|
19877
|
+
} catch (e) {
|
|
19878
|
+
this.logger.warn("ports.register(actual) \u5931\u8D25: " + e.message);
|
|
19879
|
+
}
|
|
19842
19880
|
this.events.append("api_listening", { host: this.config.apiHost, port });
|
|
19843
19881
|
this.logger.info("api listening on " + this.config.apiHost + ":" + port);
|
|
19844
19882
|
});
|
|
@@ -20340,6 +20378,10 @@ var require_supervisor = __commonJS({
|
|
|
20340
20378
|
server.listen(this.config.apiPort, this.config.apiHost, () => {
|
|
20341
20379
|
bind._tries = 0;
|
|
20342
20380
|
this.api = server;
|
|
20381
|
+
try {
|
|
20382
|
+
ports.register("supervisor-api", this.config.apiPort);
|
|
20383
|
+
} catch {
|
|
20384
|
+
}
|
|
20343
20385
|
this.events.append("api_listening", { host: this.config.apiHost, port: this.config.apiPort });
|
|
20344
20386
|
this.logger.info("api listening on " + this.config.apiHost + ":" + this.config.apiPort);
|
|
20345
20387
|
});
|
|
@@ -20720,7 +20762,8 @@ function findPackageRoot(start) {
|
|
|
20720
20762
|
return path.join(__dirname, "..");
|
|
20721
20763
|
}
|
|
20722
20764
|
var ROOT = findPackageRoot(__dirname);
|
|
20723
|
-
var
|
|
20765
|
+
var stateRoot = require_state_root();
|
|
20766
|
+
var SUPERVISOR_DIR = stateRoot.supervisorDir();
|
|
20724
20767
|
var USER_CONFIG = path.join(SUPERVISOR_DIR, "config.json");
|
|
20725
20768
|
var DEFAULT_CONFIG = Object.assign(
|
|
20726
20769
|
{},
|
|
@@ -20730,10 +20773,6 @@ var DEFAULT_CONFIG = Object.assign(
|
|
|
20730
20773
|
var STATE_FILE = path.join(SUPERVISOR_DIR, "state.json");
|
|
20731
20774
|
var EVENTS_FILE = path.join(SUPERVISOR_DIR, "events", "guard.events.log");
|
|
20732
20775
|
var UNIT_PATH = path.join(os.homedir(), ".config", "systemd", "user", "dsh-supervisor.service");
|
|
20733
|
-
var UNIT_TEMPLATE = path.join(ROOT, "systemd", "dsh-supervisor.service");
|
|
20734
|
-
var DESKTOP_DIR = path.join(os.homedir(), ".local", "share", "applications");
|
|
20735
|
-
var ICON_DIR = path.join(os.homedir(), ".local", "share", "icons");
|
|
20736
|
-
var DESKTOP_TEMPLATE = path.join(ROOT, "desktop", "dsh-supervisor.desktop");
|
|
20737
20776
|
var AUTOSTART_TEMPLATE = path.join(ROOT, "desktop", "dsh-supervisor-gui-autostart.desktop");
|
|
20738
20777
|
var AUTOSTART_FILE = path.join(os.homedir(), ".config", "autostart", "dsh-supervisor-gui-autostart.desktop");
|
|
20739
20778
|
var IS_WINDOWS = process.platform === "win32";
|
|
@@ -20866,6 +20905,8 @@ function releaseLock() {
|
|
|
20866
20905
|
}
|
|
20867
20906
|
}
|
|
20868
20907
|
function cmdDaemon() {
|
|
20908
|
+
const moved = stateRoot.migrateLegacy();
|
|
20909
|
+
for (const m of moved) console.log("[migrate] \u72B6\u6001\u76EE\u5F55\u8FC1\u79FB: " + m);
|
|
20869
20910
|
if (!acquireLock()) {
|
|
20870
20911
|
console.error("[supervisor] \u5DF2\u6709\u5B88\u536B\u5B9E\u4F8B\u5728\u8FD0\u884C\uFF08\u9501 " + LOCK_FILE + "\uFF09\uFF0C\u672C\u8FDB\u7A0B\u9000\u51FA\u3002");
|
|
20871
20912
|
process.exit(1);
|
|
@@ -20982,6 +21023,8 @@ function finishControl(r) {
|
|
|
20982
21023
|
}
|
|
20983
21024
|
}
|
|
20984
21025
|
function cmdInstall() {
|
|
21026
|
+
const moved = stateRoot.migrateLegacy();
|
|
21027
|
+
for (const m of moved) console.log("[migrate] \u72B6\u6001\u76EE\u5F55\u8FC1\u79FB: " + m);
|
|
20985
21028
|
fs.mkdirSync(SUPERVISOR_DIR, { recursive: true });
|
|
20986
21029
|
if (!fs.existsSync(USER_CONFIG)) {
|
|
20987
21030
|
fs.mkdirSync(SUPERVISOR_DIR, { recursive: true });
|
|
@@ -21004,50 +21047,8 @@ function cmdInstall() {
|
|
|
21004
21047
|
fs.symlinkSync(path.join(ROOT, "bin", "dsh-supervisor"), BIN_PATH);
|
|
21005
21048
|
console.log("[install] \u547D\u4EE4\u884C\u94FE\u63A5: " + BIN_PATH + " \u2192 " + __dirname + "/dsh-supervisor");
|
|
21006
21049
|
}
|
|
21007
|
-
|
|
21008
|
-
|
|
21009
|
-
console.warn("[install] \u5982\u9700 systemd \u5E38\u9A7B\uFF0C\u8BF7\u4ECE\u6E90\u7801\u4ED3\u5B89\u88C5\uFF08systemd/dsh-supervisor.service\uFF09\u6216\u624B\u52A8\u8FD0\u884C\uFF1Adsh-supervisor daemon");
|
|
21010
|
-
} else {
|
|
21011
|
-
let unit = fs.readFileSync(UNIT_TEMPLATE, "utf8");
|
|
21012
|
-
unit = unit.replace("@BIN@", BIN_PATH);
|
|
21013
|
-
const unitDir = path.dirname(UNIT_PATH);
|
|
21014
|
-
fs.mkdirSync(unitDir, { recursive: true });
|
|
21015
|
-
fs.writeFileSync(UNIT_PATH, unit);
|
|
21016
|
-
console.log("[install] systemd unit: " + UNIT_PATH);
|
|
21017
|
-
try {
|
|
21018
|
-
execInherit("systemctl", ["--user", "daemon-reload"]);
|
|
21019
|
-
execInherit("systemctl", ["--user", "enable", "dsh-supervisor.service"]);
|
|
21020
|
-
} catch (e) {
|
|
21021
|
-
console.warn("[install] systemctl \u6267\u884C\u5931\u8D25\uFF08\u53EF\u80FD\u4E0D\u5728 systemd \u4F1A\u8BDD\u4E2D\uFF09:", e.message);
|
|
21022
|
-
}
|
|
21023
|
-
try {
|
|
21024
|
-
execInherit("loginctl", ["enable-linger", os.userInfo().username]);
|
|
21025
|
-
console.log("[install] loginctl enable-linger \u5DF2\u542F\u7528");
|
|
21026
|
-
} catch {
|
|
21027
|
-
console.warn("[install] enable-linger \u5931\u8D25\uFF0C\u5F00\u673A\u81EA\u542F\u53EF\u80FD\u4E0D\u751F\u6548");
|
|
21028
|
-
}
|
|
21029
|
-
installDesktopEntry();
|
|
21030
|
-
console.log("\n\u5B89\u88C5\u5B8C\u6210\u3002\u542F\u52A8\u5B88\u536B\uFF1A\n systemctl --user start dsh-supervisor");
|
|
21031
|
-
console.log("\u67E5\u770B\u72B6\u6001\uFF1A\n dsh-supervisor status");
|
|
21032
|
-
}
|
|
21033
|
-
}
|
|
21034
|
-
function installDesktopEntry() {
|
|
21035
|
-
try {
|
|
21036
|
-
if (!fs.existsSync(DESKTOP_TEMPLATE)) return;
|
|
21037
|
-
fs.mkdirSync(ICON_DIR, { recursive: true });
|
|
21038
|
-
const shellDir = process.env.DSH_SHELL_DIR || null;
|
|
21039
|
-
const iconSrc = shellDir ? path.join(shellDir, "src-tauri", "icons", "128x128.png") : null;
|
|
21040
|
-
const iconDst = path.join(ICON_DIR, "dsh-supervisor.png");
|
|
21041
|
-
if (iconSrc && fs.existsSync(iconSrc)) fs.copyFileSync(iconSrc, iconDst);
|
|
21042
|
-
else console.warn("[install] \u672A\u627E\u5230\u58F3\u56FE\u6807\uFF08\u53EF\u8BBE DSH_SHELL_DIR \u6307\u5411\u58F3 checkout\uFF09\uFF0C\u684C\u9762\u56FE\u6807\u7F3A\u5931\uFF1B\u4E0D\u5F71\u54CD\u529F\u80FD\u3002");
|
|
21043
|
-
fs.mkdirSync(DESKTOP_DIR, { recursive: true });
|
|
21044
|
-
const entry = fs.readFileSync(DESKTOP_TEMPLATE, "utf8").replace(/@HOME@/g, os.homedir());
|
|
21045
|
-
const dst = path.join(DESKTOP_DIR, "dsh-supervisor.desktop");
|
|
21046
|
-
fs.writeFileSync(dst, entry);
|
|
21047
|
-
console.log("[install] \u684C\u9762\u83DC\u5355\u5165\u53E3: " + dst);
|
|
21048
|
-
} catch (e) {
|
|
21049
|
-
console.warn("[install] \u684C\u9762\u5165\u53E3\u90E8\u7F72\u5931\u8D25:", e.message);
|
|
21050
|
-
}
|
|
21050
|
+
console.log("[install] \u670D\u52A1\u5B9A\u4E49/\u5F00\u673A\u81EA\u542F/\u684C\u9762\u5165\u53E3\u7531\u684C\u9762\u58F3\u8D1F\u8D23\uFF08\u672C\u547D\u4EE4\u4E0D\u518D\u90E8\u7F72\uFF09\u3002");
|
|
21051
|
+
console.log("[install] \u5185\u6838\u672C\u4F53\u5DF2\u5C31\u7EEA\u3002\u542F\u52A8\u7531\u684C\u9762\u58F3\u6216\u670D\u52A1\u7BA1\u7406\u5668\u53D1\u8D77\uFF1Adsh-supervisor daemon");
|
|
21051
21052
|
}
|
|
21052
21053
|
function cmdGuiAutostart(onoff) {
|
|
21053
21054
|
if (onoff === "on") {
|