@drocketxx/pm2me 1.1.24 → 1.1.26

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.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/png" href="/icon.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>PM2Me</title>
8
- <script type="module" crossorigin src="/assets/index-B7WRj0k0.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-CtXHqzy0.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-Bo3lbcQo.css">
10
10
  </head>
11
11
  <body>
@@ -1059,27 +1059,61 @@ router.post('/system/update', async (req, res) => {
1059
1059
  const isGlobal = !fs.existsSync(path.resolve(__dirname, '../../.git'));
1060
1060
  let cmd, cwd;
1061
1061
  if (isGlobal) {
1062
- // Run in background/detached mode so it continues after service uninstall
1062
+ // Create update script that runs independently
1063
1063
  if (isWindows) {
1064
- cmd = 'powershell -Command "Start-Process powershell -ArgumentList \'-Command\',\'npm cache clean --force; npm install -g @drocketxx/pm2me@latest --force; pm2me service uninstall; pm2me service install\' -WindowStyle Hidden"';
1064
+ // Windows: Create PowerShell script and execute with Start-Process
1065
+ const scriptPath = path.join(os.tmpdir(), 'pm2me-update.ps1');
1066
+ const scriptContent = `Start-Sleep -Seconds 3
1067
+ npm cache clean --force
1068
+ npm install -g @drocketxx/pm2me@latest --force
1069
+ pm2me service uninstall
1070
+ Start-Sleep -Seconds 3
1071
+ pm2me service install
1072
+ Remove-Item -Path "${scriptPath}" -Force`;
1073
+ fs.writeFileSync(scriptPath, scriptContent);
1074
+ cmd = `powershell -Command "Start-Process -FilePath 'powershell' -ArgumentList '-ExecutionPolicy','Bypass','-File','${scriptPath}' -WindowStyle Hidden"`;
1075
+
1076
+ exec(cmd, { windowsHide: true });
1065
1077
  } else {
1066
- cmd = 'nohup sh -c "npm cache clean --force && npm install -g @drocketxx/pm2me@latest --force && pm2me service uninstall && pm2me service install" > /tmp/pm2me-update.log 2>&1 &';
1078
+ // Linux: Use at command or systemd-run if available, otherwise use disown
1079
+ const scriptPath = '/tmp/pm2me-update.sh';
1080
+ const scriptContent = `#!/bin/bash
1081
+ sleep 3
1082
+ npm cache clean --force
1083
+ npm install -g @drocketxx/pm2me@latest --force
1084
+ pm2me service uninstall
1085
+ sleep 3
1086
+ pm2me service install
1087
+ rm -f ${scriptPath}`;
1088
+ fs.writeFileSync(scriptPath, scriptContent, { mode: 0o755 });
1089
+
1090
+ // Try to use systemd-run first (most reliable), fallback to at, then to background process
1091
+ try {
1092
+ // Check if systemd-run is available
1093
+ await execAsync('which systemd-run');
1094
+ cmd = `systemd-run --user --on-active=3s ${scriptPath}`;
1095
+ } catch {
1096
+ try {
1097
+ // Check if at is available
1098
+ await execAsync('which at');
1099
+ cmd = `echo "${scriptPath}" | at now + 3 seconds 2>&1`;
1100
+ } catch {
1101
+ // Fallback to background process with setsid (detach from session)
1102
+ cmd = `(sleep 3 && ${scriptPath}) >/tmp/pm2me-update.log 2>&1 </dev/null & disown`;
1103
+ }
1104
+ }
1105
+
1106
+ exec(cmd, { shell: '/bin/bash', detached: true });
1067
1107
  }
1068
- cwd = '/';
1069
- } else {
1070
- cmd = 'git pull origin main && npm run build';
1071
- cwd = path.resolve(__dirname, '../..');
1072
- }
1073
-
1074
- // For global install, spawn detached and return immediately
1075
- if (isGlobal) {
1076
- exec(cmd, { cwd, windowsHide: true, detached: true });
1108
+
1077
1109
  res.json({
1078
1110
  success: true,
1079
- output: 'Update started in background. Service will restart automatically in ~30 seconds.',
1111
+ output: 'Update scheduled. Service will restart in ~30 seconds.',
1080
1112
  cmd
1081
1113
  });
1082
1114
  } else {
1115
+ cmd = 'git pull origin main && npm run build';
1116
+ cwd = path.resolve(__dirname, '../..');
1083
1117
  const { stdout, stderr } = await execAsync(cmd, { cwd, windowsHide: true }).catch(err => ({
1084
1118
  stdout: '', stderr: err.message
1085
1119
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drocketxx/pm2me",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
4
4
  "description": "PM2 Deployment and Management System — Web UI for PM2 process management",
5
5
  "type": "module",
6
6
  "main": "backend/app.js",