PM2 runs under its own systemd unit, never as a child of the agent

Found in the VM test: a site's PM2 daemon started from the agent's install
job belonged to the agent's service, so stopping or updating the agent took
down every site it had installed. Before any PM2 command as a site user,
the scripts now make sure that user's daemon runs under pm2-<user> (moving
one that runs elsewhere, keeping its process list). The agent's stats no
longer start an empty daemon by asking one that isn't running. Uninstall
stops the unit before removing it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 16:40:12 +02:00
co-authored by Claude Opus 5.5
parent 19709c2c75
commit 570f2dda5a
4 changed files with 44 additions and 2 deletions
-1
View File
@@ -261,7 +261,6 @@ install_events() {
undo_add pm2 "$user" "$name-backend $name-frontend"
run_as "$user" "$app" pm2 startOrReload ecosystem.config.js
run_as "$user" "$app" pm2 save
env PATH="$PATH:/usr/bin" pm2 startup systemd -u "$user" --hp "$(getent passwd "$user" | cut -d: -f6)" >/dev/null
if [ "$frp" = 1 ]; then
step "Events: frpc tunnels"