Pm2 changes cwd on hard reboot
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
What's going wrong?
I have only one node js app daemonized on server which i started with apps.json file
everything works fine until server shuts down
After that pm2 changes cwd value to user home folder ("/home/admin")
last time this happened when i forgot to pay server bill and my provider shut it down
I belive this happens on hard reboot
How could we reproduce this issue?
start node js app with apps.json file
pm2 start apps.json
pm2 startup
pm2 save
and hard reboot server
Supporting information
apps.json file
{
"apps": [
{
"name": "sasa_front",
"cwd": "/home/admin/apps/sasa_front",
"script": "npm",
"args": "start",
}
]
}
--- Daemon logs --------------------------------------------
PM2 | 2022-07-23T10:23:58: PM2 log: App [sasa_front:0] starting in -fork mode-
PM2 | 2022-07-23T10:23:58: PM2 log: App [sasa_front:0] online
PM2 | 2022-07-23T10:23:59: PM2 log: App [sasa_front:0] exited with code [254] via signal [SIGINT]
PM2 | 2022-07-23T10:23:59: PM2 log: App [sasa_front:0] starting in -fork mode-
PM2 | 2022-07-23T10:23:59: PM2 log: App [sasa_front:0] online
PM2 | 2022-07-23T10:23:59: PM2 log: App [sasa_front:0] exited with code [254] via signal [SIGINT]
PM2 | 2022-07-23T10:23:59: PM2 log: App [sasa_front:0] starting in -fork mode-
PM2 | 2022-07-23T10:23:59: PM2 log: App [sasa_front:0] online
PM2 | 2022-07-23T10:23:59: PM2 log: App [sasa_front:0] exited with code [254] via signal [SIGINT]
PM2 | 2022-07-23T10:23:59: PM2 log: App [sasa_front:0] starting in -fork mode-
PM2 | 2022-07-23T10:23:59: PM2 log: App [sasa_front:0] online
PM2 | 2022-07-23T10:24:00: PM2 log: App [sasa_front:0] exited with code [254] via signal [SIGINT]
PM2 | 2022-07-23T10:24:00: PM2 log: App [sasa_front:0] starting in -fork mode-
PM2 | 2022-07-23T10:24:00: PM2 log: App [sasa_front:0] online
PM2 | 2022-07-23T10:24:00: PM2 log: App [sasa_front:0] exited with code [254] via signal [SIGINT]
PM2 | 2022-07-23T10:24:00: PM2 log: Script /usr/bin/npm had too many unstable restarts (16). Stopped. "errored"
PM2 | 2022-07-23T10:25:48: PM2 log: Stopping app:sasa_front id:0
PM2 | 2022-07-23T10:25:48: PM2 error: app=sasa_front id=0 does not have a pid
PM2 | 2022-07-23T10:25:53: PM2 log: App [sasa_front:0] starting in -fork mode-
PM2 | 2022-07-23T10:25:53: PM2 log: App [sasa_front:0] online
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided apps.json and the pm2 startup/save sequence, then inspect the startup restoration path that handles the configured cwd after a hard reboot. Done means the app is restored with /home/admin/apps/sasa_front as its cwd and no longer enters the unstable-restart loop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100