@oxiaom/adoremix 1.0.77 → 1.0.79
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/cli.js +3 -0
- package/src/service/linux.js +21 -1
- package/templates/adoremix.service.tmpl +1 -0
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -261,6 +261,9 @@ function buildProgram() {
|
|
|
261
261
|
// status 不委托(pidfile 检查已与 systemctl 一致)。仅 Linux + 服务 active 时生效。
|
|
262
262
|
function systemdDelegate(cmd) {
|
|
263
263
|
if (process.platform !== 'linux') return false;
|
|
264
|
+
// 由 systemd 单元自身启动时(ADOREMIX_UNDER_SYSTEMD=1),不能再 systemctl start 自己,
|
|
265
|
+
// 否则 CLI 立即返回 → 主进程退出 → systemd 认为服务结束
|
|
266
|
+
if (process.env.ADOREMIX_UNDER_SYSTEMD === '1') return false;
|
|
264
267
|
const { execSync } = require('child_process');
|
|
265
268
|
let active;
|
|
266
269
|
try {
|
package/src/service/linux.js
CHANGED
|
@@ -31,10 +31,30 @@ function chownWorkdir(workdir, username) {
|
|
|
31
31
|
execSync(`chown -R ${username}:${username} ${workdir}`);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// Node 是否可被服务用户执行:root 下的 nvm 安装(/root/.nvm)adoremix 用户无法访问,
|
|
35
|
+
// systemd 会报 203/EXEC。检测失败时回退为 root 运行并提示。
|
|
36
|
+
function nodeUsableByServiceUser(nodePath) {
|
|
37
|
+
if (!isSystemMode()) return true;
|
|
38
|
+
if (nodePath.startsWith('/root/')) return false;
|
|
39
|
+
try {
|
|
40
|
+
execSync(`runuser -u adoremix -- test -x "${nodePath}"`, { stdio: 'ignore' });
|
|
41
|
+
return true;
|
|
42
|
+
} catch (e) {
|
|
43
|
+
// runuser 不存在时按路径判断,避免误报
|
|
44
|
+
if (e.status === 127) return true;
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
34
49
|
function fillTemplate(workdir) {
|
|
35
50
|
const tplPath = path.join(__dirname, '..', '..', 'templates', 'adoremix.service.tmpl');
|
|
36
51
|
let tpl = fs.readFileSync(tplPath, 'utf8');
|
|
37
|
-
|
|
52
|
+
let user = isSystemMode() ? 'adoremix' : os.userInfo().username;
|
|
53
|
+
if (isSystemMode() && !nodeUsableByServiceUser(paths.nodeExecutable())) {
|
|
54
|
+
user = 'root';
|
|
55
|
+
logger.warn('Node 安装在 /root 下(nvm),服务用户 adoremix 无法执行;服务将改为 root 运行。');
|
|
56
|
+
logger.warn('建议把 Node 安装到系统路径(/usr/bin/node)后重新执行 adoremix service install。');
|
|
57
|
+
}
|
|
38
58
|
const node = paths.nodeExecutable();
|
|
39
59
|
const cli = paths.cliBin();
|
|
40
60
|
return tpl
|