@drocketxx/pm2me 1.1.28 → 1.1.30

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.
@@ -1123,24 +1123,50 @@ Remove-Item -Path "${scriptPath}" -Force`;
1123
1123
  cmd = `powershell -Command "Start-Process -FilePath 'powershell' -ArgumentList '-ExecutionPolicy','Bypass','-File','${scriptPath}' -WindowStyle Hidden"`;
1124
1124
 
1125
1125
  exec(cmd, { windowsHide: true });
1126
+
1127
+ res.json({
1128
+ success: true,
1129
+ output: `Update scheduled. Service will restart in ~30 seconds.\nLog: ${logPath}`,
1130
+ cmd
1131
+ });
1126
1132
  } else {
1127
- // Linux: Use at command or systemd-run if available, otherwise use disown
1133
+ // Linux: Get full paths to npm and pm2me before running detached
1134
+ let npmPath, pm2mePath;
1135
+ try {
1136
+ const npmResult = await execAsync('which npm');
1137
+ npmPath = npmResult.stdout.trim();
1138
+ } catch {
1139
+ npmPath = '/usr/bin/npm'; // fallback
1140
+ }
1141
+ try {
1142
+ const pm2meResult = await execAsync('which pm2me');
1143
+ pm2mePath = pm2meResult.stdout.trim();
1144
+ } catch {
1145
+ pm2mePath = 'pm2me'; // fallback to PATH
1146
+ }
1147
+
1128
1148
  const scriptPath = '/tmp/pm2me-update.sh';
1129
1149
  const logPath = '/tmp/pm2me-update.log';
1130
1150
  const scriptContent = `#!/bin/bash
1151
+ # Source user environment to get proper PATH
1152
+ [ -f ~/.bashrc ] && source ~/.bashrc
1153
+ [ -f ~/.profile ] && source ~/.profile
1154
+
1131
1155
  exec > ${logPath} 2>&1
1132
1156
  echo "[$(date)] PM2Me Update Script Started"
1157
+ echo "[$(date)] Using npm: ${npmPath}"
1158
+ echo "[$(date)] Using pm2me: ${pm2mePath}"
1133
1159
  sleep 3
1134
1160
 
1135
1161
  echo "[$(date)] Cleaning npm cache..."
1136
- npm cache clean --force || echo "Cache clean failed (non-critical)"
1162
+ ${npmPath} cache clean --force || echo "Cache clean failed (non-critical)"
1137
1163
 
1138
1164
  echo "[$(date)] Installing latest version from npm..."
1139
- if npm install -g @drocketxx/pm2me@latest --force; then
1165
+ if ${npmPath} install -g @drocketxx/pm2me@latest --force; then
1140
1166
  echo "[$(date)] Successfully installed latest version"
1141
1167
  else
1142
1168
  echo "[$(date)] ERROR: npm install failed - trying with sudo..."
1143
- if sudo -n npm install -g @drocketxx/pm2me@latest --force 2>/dev/null; then
1169
+ if sudo -n ${npmPath} install -g @drocketxx/pm2me@latest --force 2>/dev/null; then
1144
1170
  echo "[$(date)] Successfully installed with sudo"
1145
1171
  else
1146
1172
  echo "[$(date)] FATAL: npm install failed. Update aborted."
@@ -1149,12 +1175,12 @@ else
1149
1175
  fi
1150
1176
 
1151
1177
  echo "[$(date)] Uninstalling old service..."
1152
- pm2me service uninstall || echo "Service uninstall failed (might not exist)"
1178
+ ${pm2mePath} service uninstall || echo "Service uninstall failed (might not exist)"
1153
1179
 
1154
1180
  sleep 3
1155
1181
 
1156
1182
  echo "[$(date)] Installing new service..."
1157
- if pm2me service install; then
1183
+ if ${pm2mePath} service install; then
1158
1184
  echo "[$(date)] Service installed successfully"
1159
1185
  else
1160
1186
  echo "[$(date)] ERROR: Service install failed"
@@ -1182,13 +1208,13 @@ rm -f ${scriptPath}`;
1182
1208
  }
1183
1209
 
1184
1210
  exec(cmd, { shell: '/bin/bash', detached: true });
1211
+
1212
+ res.json({
1213
+ success: true,
1214
+ output: `Update scheduled. Service will restart in ~30 seconds.\nUsing npm: ${npmPath}\nUsing pm2me: ${pm2mePath}\nLog: ${logPath}`,
1215
+ cmd
1216
+ });
1185
1217
  }
1186
-
1187
- res.json({
1188
- success: true,
1189
- output: 'Update scheduled. Service will restart in ~30 seconds.',
1190
- cmd
1191
- });
1192
1218
  } else {
1193
1219
  cmd = 'git pull origin main && npm run build';
1194
1220
  cwd = path.resolve(__dirname, '../..');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drocketxx/pm2me",
3
- "version": "1.1.28",
3
+ "version": "1.1.30",
4
4
  "description": "PM2 Deployment and Management System — Web UI for PM2 process management",
5
5
  "type": "module",
6
6
  "main": "backend/app.js",