@drocketxx/pm2me 1.1.30 → 1.1.32
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/backend/routes/api.js +17 -8
- package/package.json +1 -1
package/backend/routes/api.js
CHANGED
|
@@ -1130,30 +1130,39 @@ Remove-Item -Path "${scriptPath}" -Force`;
|
|
|
1130
1130
|
cmd
|
|
1131
1131
|
});
|
|
1132
1132
|
} else {
|
|
1133
|
-
// Linux: Get full paths to npm and
|
|
1134
|
-
let npmPath, pm2mePath;
|
|
1133
|
+
// Linux: Get full paths to npm, pm2me, and node before running detached
|
|
1134
|
+
let npmPath, pm2mePath, nodePath, binDir;
|
|
1135
1135
|
try {
|
|
1136
1136
|
const npmResult = await execAsync('which npm');
|
|
1137
1137
|
npmPath = npmResult.stdout.trim();
|
|
1138
|
+
binDir = path.dirname(npmPath); // e.g., /root/.nvm/versions/node/v22.21.1/bin
|
|
1138
1139
|
} catch {
|
|
1139
|
-
npmPath = '/usr/bin/npm';
|
|
1140
|
+
npmPath = '/usr/bin/npm';
|
|
1141
|
+
binDir = '/usr/bin';
|
|
1140
1142
|
}
|
|
1141
1143
|
try {
|
|
1142
1144
|
const pm2meResult = await execAsync('which pm2me');
|
|
1143
1145
|
pm2mePath = pm2meResult.stdout.trim();
|
|
1144
1146
|
} catch {
|
|
1145
|
-
pm2mePath = 'pm2me';
|
|
1147
|
+
pm2mePath = 'pm2me';
|
|
1148
|
+
}
|
|
1149
|
+
try {
|
|
1150
|
+
const nodeResult = await execAsync('which node');
|
|
1151
|
+
nodePath = nodeResult.stdout.trim();
|
|
1152
|
+
} catch {
|
|
1153
|
+
nodePath = path.join(binDir, 'node'); // Same dir as npm
|
|
1146
1154
|
}
|
|
1147
1155
|
|
|
1148
1156
|
const scriptPath = '/tmp/pm2me-update.sh';
|
|
1149
1157
|
const logPath = '/tmp/pm2me-update.log';
|
|
1150
1158
|
const scriptContent = `#!/bin/bash
|
|
1151
|
-
#
|
|
1152
|
-
|
|
1153
|
-
[ -f ~/.profile ] && source ~/.profile
|
|
1159
|
+
# Add Node.js bin directory to PATH
|
|
1160
|
+
export PATH="${binDir}:$PATH"
|
|
1154
1161
|
|
|
1155
1162
|
exec > ${logPath} 2>&1
|
|
1156
1163
|
echo "[$(date)] PM2Me Update Script Started"
|
|
1164
|
+
echo "[$(date)] PATH: $PATH"
|
|
1165
|
+
echo "[$(date)] Using node: ${nodePath}"
|
|
1157
1166
|
echo "[$(date)] Using npm: ${npmPath}"
|
|
1158
1167
|
echo "[$(date)] Using pm2me: ${pm2mePath}"
|
|
1159
1168
|
sleep 3
|
|
@@ -1211,7 +1220,7 @@ rm -f ${scriptPath}`;
|
|
|
1211
1220
|
|
|
1212
1221
|
res.json({
|
|
1213
1222
|
success: true,
|
|
1214
|
-
output: `Update scheduled. Service will restart in ~30 seconds.\
|
|
1223
|
+
output: `Update scheduled. Service will restart in ~30 seconds.\nBin Dir: ${binDir}\nNode: ${nodePath}\nNpm: ${npmPath}\nPm2me: ${pm2mePath}\nLog: ${logPath}`,
|
|
1215
1224
|
cmd
|
|
1216
1225
|
});
|
|
1217
1226
|
}
|