PM2 on Windows Server

One standard PM2, installed by you, in your own profile. In Server mode the background service runs as a different Windows account and cannot use it — and Easy DevOps says so instead of creating a second one.

The PM2 Easy DevOps uses

There is exactly one PM2 model, and it is yours: the standard PM2 anyone installs with npm i -g pm2, with the default PM2_HOME of that account — for example C:\Users\admin\.pm2. Easy DevOps does not create its own PM2, does not set a PM2_HOME of its own, does not install a second copy, does not start a second PM2 daemon, and never moves, restarts or touches an app you already have.

Which process talks to that PM2 depends on how Easy DevOps runs on the machine:

Where Easy DevOps runsAccountIts PM2
Linux servicethe installing user — root on a root installthe same account, so the daemon, the CLI, deploys and PM2 are one identity. Unchanged in 1.4.9.
Windows Personalyou, at logon (a Startup-folder supervisor)yours, because it is the same account.
Windows Serverthe service, as NT SERVICE\EasyDevOpscannot use yours. The dashboard and the CLI, run by you, still do.

PM2 is optional. Easy DevOps itself is a native service, not a PM2 app, and it runs without PM2 at all; PM2 is what runs the apps you deploy or start yourself, from the Processes and Deployments pages or from your own terminal.

Why the service cannot see that PM2

In Windows Server mode the background service is a real Windows service running as the virtual account NT SERVICE\EasyDevOps, with no password and no profile of yours. Three facts each make your PM2 invisible to it:

  • The npm global prefix is per user. npm i -g pm2 as admin writes pm2.cmd into C:\Users\admin\AppData\Roaming\npm, which is on that user's PATH only. The service account's where.exe pm2 finds nothing.
  • PM2_HOME is per user. Without an explicit PM2_HOME, PM2 uses the profile of whoever runs it. The service account's profile is not C:\Users\admin\.pm2, so its pid file, dump and logs are not yours either.
  • Running pm2 as the service would start a second daemon. Every PM2 command starts a PM2 daemon when none answers it. On Windows, PM2's RPC pipe names are fixed machine-wide rather than per PM2_HOME, so a command issued as the service is not a safe read-only probe: it can leave a daemon owned by the service account that you cannot see or stop.

So the service does the one safe thing: it never spawns pm2 or npm, reports what it knows, and stops. Nothing is created, nothing is converted, no migration runs and no app is touched.

note

This is why the Hub shows PM2 runs under the user admin; the Easy DevOps service (NT SERVICE\EasyDevOps) cannot see it. It is a statement about accounts, not about a missing installation.

What the Hub shows and refuses

Since 1.4.9 the agent reports the service from inside the service — installed, Windows service mode, starting at boot, the account it runs as, the version and the data directory — and sends an explicit PM2 record on every push, in both service:state and processes:list. A missing field means unknown, never false, so an older Hub keeps working with a 1.4.9 agent and the other way round.

PM2 stateWhat it meansWhat to do
available / emptyThe PM2 daemon answered, with apps or with none. This is what the operator's dashboard and CLI see.Nothing.
not_runningPM2 is installed but its daemon is not up. The read never starts one.Start an app with PM2, or run pm2 resurrect.
not_installedThere is no PM2 this process can use.Run npm i -g pm2 on the server.
unavailableThe service account may not use PM2 (service_account), or PM2 did not answer (list_failed). The record carries message, fix and, when known, user.Follow the fix text; on Windows Server that means managing the apps on the server as the user who runs PM2.

With the operator recorded, the Hub shows the exact sentence and next step. Without it the texts are still honest and name the gap:

Hub - PM2 unavailable
PM2 runs under the user admin; the Easy DevOps service (NT SERVICE\EasyDevOps) cannot see it.
Manage these apps on the server as admin (the Easy DevOps dashboard there, or pm2 list).
Hub process actions and Hub deploys need that PM2, so this server refuses them.

# or, when install/repair could not record the account:
PM2 runs under the account that started it; the Easy DevOps service (NT SERVICE\EasyDevOps) cannot see it.
Run ezz service repair in an Administrator PowerShell, signed in as the user who runs PM2,
so the Hub can name that user. Manage the apps on the server meanwhile.

In Windows Server mode the agent therefore refuses to act, and refuses before anything is spawned, listed or changed:

  • Hub process actions (start, stop, restart) are refused with the reason above; no pm2 runs.
  • Hub deploys are refused the same way, before the deploy lock is taken, before a run record or release folder is written and before any step runs — a refused deploy leaves nothing half-built behind.
  • The Processes area shows the reason and the next step instead of PM2 is not installed or an endless Waiting for the process list….

What still manages your apps

Everything you run on the server as the user who owns PM2 keeps working exactly as before. That is the answer to a Hub that refuses: use one of these.

Entry pointWhat it does with your PM2
Local dashboardThe Processes page lists your apps and starts, stops and restarts them; the Deployments page deploys, rolls back and reports health under your PM2. Opened from the server as admin, it sees exactly what pm2 list sees.
CLIThe same PM2 as the dashboard, because it is the same account. Deployments are started from the dashboard, the Hub or CI; the CLI has no deploy-app creation path.
Your terminalpm2 list, pm2 logs and the rest, as that user, are the ground truth.

The account matters more than the tool: Easy DevOps reads the PM2 of the account it runs as, and PM2 keeps its daemon, pid file and dump per user. A dashboard started as a different Windows user therefore does not report yours — run it as the user who installed PM2. The Processes page names that account in its PM2 heading for exactly this reason.

After a reboot

This part is deliberately blunt, because nothing Easy DevOps does changes it:

  • PM2 has no startup mechanism on Windows. pm2 startup understands Linux init systems only; there is no Windows equivalent.
  • Easy DevOps installs no boot hook for PM2 apps. The Windows service starts the Easy DevOps daemon, not your PM2 apps, and no installer or repair step writes a PM2 startup task.
  • So apps started under a user's PM2 do not come back after a reboot until that user signs in and runs pm2 resurrect, using the dump written earlier by pm2 save.
PowerShell - after signing in
# save the current app list while it is the one you want
pm2 save

# after a reboot: sign in as the same user, then
pm2 resurrect
pm2 list

There is no setting that makes this survive a reboot with nobody signed in while keeping the one-PM2 model; a launcher that runs at logon or a scheduled task would still wait for a sign-in. If apps must be up with no session, run them as a Windows service of their own, not under a user's PM2.

Linux is different for one reason: the account. On a root install the systemd unit and PM2 both run as root, so PM2's own pm2 startup plus pm2 save restores the apps at boot with no login. Easy DevOps does not install that hook either — it is PM2's command, run once by you.

Telling the Hub which user runs PM2

ezz service install records the account that ran it — name, home and the PM2 path it found — beside the SID the Windows permissions already use. The record is written by the CLI process, never by the daemon, because only the CLI can see your profile. A value it cannot read never replaces a recorded one.

An install made before 1.4.9 has the SID but not that profile, so the Hub can only say the account that started it. Give it the name in one step:

Administrator PowerShell
# signed in as the user who runs PM2
ezz service repair

Repair re-registers the service definition and re-pins the runtime exactly as before, refreshes the operator record and leaves data and certificates untouched. Afterwards the Hub's message names the user and the fix. Installing as an administrator who does not run PM2 records that administrator; run repair as the PM2 user to correct it.

Installing PM2

PM2 is installed with the standard command, as you, into your own npm prefix and default PM2_HOME. Three places offer it, and none of them ever installs it silently:

WhereHow
The installerAsked after Easy DevOps is installed and before the background-service offer, only when PM2 is missing and only with a terminal. The default answer is No; with no terminal it prints the command and installs nothing. A failed PM2 install never fails the Easy DevOps install.
The dashboardAn Install PM2 button on the Deployments page, shown with the warning when PM2 is missing. It runs the same npm i -g pm2 (no body, behind the dashboard session).
Your terminalnpm i -g pm2. Always correct, and the only way on the Hub, which shows the command rather than installing remotely.

The installer flags, when you want to skip the question:

ScriptInstall without askingNever install
install.sh--pm2--no-pm2
install.ps1-Pm2-NoPm2
install.bat--pm2 → -Pm2--no-pm2 → -NoPm2
Linux installer
# the offer, only when PM2 is missing and there is a terminal
  Easy DevOps runs the apps it deploys with PM2, and shows the PM2 apps
  you already have. PM2 is not installed yet.

  It would be installed globally, for the account running this installer
  (admin), with that account's npm and its usual PM2 home. Nothing else
  is created, and existing apps are not touched.

  Install PM2 now? [y/N]

# no terminal: nothing is installed and nothing is guessed
  PM2 is not installed.
  No terminal is available, so it was not installed. Install it with:
    npm i -g pm2

On Windows Server the installer adds one honest line after a successful install: the PM2 it just installed belongs to the account that ran the installer, and the background service runs as NT SERVICE\EasyDevOps and cannot use another account's PM2 — so Easy DevOps reports that instead of creating a second one. Creating your first deploy app when PM2 is missing does not fail: the app is created (creating it does not start it) and the response carries the same offer, which the Deployments page turns into the Install PM2 button.

Migration: none

There is nothing to migrate and nothing is migrated. The owner's decision is the standard PM2 of the operator, unchanged, and 1.4.9 adds no Easy DevOps-owned PM2, no PM2_HOME under C:\ProgramData, no second daemon and no move of any app. An existing app keeps its name, its folder, its dump entry and the account it runs as.

The only change a server sees is what Easy DevOps reports and what it refuses: the Hub names the account whose PM2 the machine uses, and says why it cannot act on it, instead of calling a working PM2 "not installed".

related

Background Service for the Windows service itself, Deployments for what runs under PM2, and Troubleshooting when the Hub still shows the old labels.