@wendongfly/myhi 1.3.27 → 1.3.28

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/bin/myhi.js CHANGED
@@ -696,14 +696,21 @@ SSH 开发:
696
696
  const port = process.env.PORT || '12300';
697
697
  const serviceFile = '/etc/systemd/system/myhi.service';
698
698
 
699
+ // 找到 node 和 daemon.js 的路径,用 Type=simple 直接前台运行 daemon
700
+ let nodeBin;
701
+ try { nodeBin = ex('which node', { encoding: 'utf8' }).trim(); } catch { nodeBin = '/usr/bin/node'; }
702
+ // myhi bin 可能是 symlink,解析真实路径后找到同目录的 daemon.js
703
+ let realMyhiBin;
704
+ try { realMyhiBin = ex(`readlink -f ${myhiBin}`, { encoding: 'utf8' }).trim(); } catch { realMyhiBin = myhiBin; }
705
+ const daemonScript = join(dirname(realMyhiBin), 'daemon.js');
706
+
699
707
  const unitContent = `[Unit]
700
708
  Description=myhi - Web Terminal Sharing
701
709
  After=network.target
702
710
 
703
711
  [Service]
704
- Type=forking
705
- PIDFile=${home}/.myhi/daemon.pid
706
- ExecStart=${myhiBin} -d
712
+ Type=simple
713
+ ExecStart=${nodeBin} ${daemonScript}
707
714
  ExecStop=${myhiBin} stop
708
715
  WorkingDirectory=${cwd}
709
716
  Restart=on-failure