Question Windows: how to hardset pm2 daemon working directory regardless the location from where pm2 is run
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
pm2 start myapp starts myappbased on my ecosystem.config.js. This runs my app inside the cwd directory configured in ecosystem.config.js.
So my app process is a child process of node C:\Users\sebtr\AppData\Roaming\npm\node_modules\pm2\lib\Daemon.js which has a working directory equal to the location where I ran the pm2 start myapp command.
I wish I could hardset the pm2 daemon working directory, no matter the location from where the first pm2 start command is run.
Is there any pm2 command option or environment variable that could hardset the pm2 daemon cwd please?
$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date : Wed Dec 16 2020 12:25:55 GMT+0100 (Central European Standard Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 4.4.0
node version : 13.13.0
node path : not found
argv : C:\Program Files\nodejs\node.exe,C:\Users\sebtr\AppData\Roaming\npm\node_modules\pm2\lib\Daemon.js
argv0 : node
user : undefined
uid : N/A
gid : N/A
uptime : 3min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 4.4.0
node version : 13.13.0
node path : not found
argv : C:\Program Files\nodejs\node.exe,C:\Users\sebtr\AppData\Roaming\npm\node_modules\pm2\bin\pm2,report
argv0 : node
user : sebtr
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : win32
type : Windows_NT
cpus : Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
cpus nb : 8
freemem : 20682903552
totalmem : 34213875712
home : C:\Users\sebtr
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬───────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼───────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ my-app │ default │ 0.1.0 │ fork │ 18576 │ 3m │ 0 │ online │ 0% │ 36.6mb │ sebtr │ disabled │
└─────┴───────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
C:\Users\sebtr\.pm2\pm2.log last 20 lines:
PM2 | 2020-12-16T12:21:40: PM2 log: ===============================================================================
PM2 | 2020-12-16T12:22:09: PM2 log: PM2 successfully stopped
PM2 | 2020-12-16T12:22:10: PM2 log: ===============================================================================
PM2 | 2020-12-16T12:22:10: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2 | 2020-12-16T12:22:10: PM2 log: Time : Wed Dec 16 2020 12:22:10 GMT+0100 (Central European Standard Time)
PM2 | 2020-12-16T12:22:10: PM2 log: PM2 version : 4.4.0
PM2 | 2020-12-16T12:22:10: PM2 log: Node.js version : 13.13.0
PM2 | 2020-12-16T12:22:10: PM2 log: Current arch : x64
PM2 | 2020-12-16T12:22:10: PM2 log: PM2 home : C:\Users\sebtr\.pm2
PM2 | 2020-12-16T12:22:10: PM2 log: PM2 PID file : C:\Users\sebtr\.pm2\pm2.pid
PM2 | 2020-12-16T12:22:10: PM2 log: RPC socket file : \\.\pipe\rpc.sock
PM2 | 2020-12-16T12:22:10: PM2 log: BUS socket file : \\.\pipe\pub.sock
PM2 | 2020-12-16T12:22:10: PM2 log: Application log path : C:\Users\sebtr\.pm2\logs
PM2 | 2020-12-16T12:22:10: PM2 log: Worker Interval : 30000
PM2 | 2020-12-16T12:22:10: PM2 log: Process dump file : C:\Users\sebtr\.pm2\dump.pm2
PM2 | 2020-12-16T12:22:10: PM2 log: Concurrent actions : 2
PM2 | 2020-12-16T12:22:10: PM2 log: SIGTERM timeout : 1600
PM2 | 2020-12-16T12:22:10: PM2 log: ===============================================================================
PM2 | 2020-12-16T12:22:13: PM2 log: App [ftl-node-agent:0] starting in -fork mode-
PM2 | 2020-12-16T12:22:14: PM2 log: App [ftl-node-agent: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
Reproduce the Windows behavior with pm2 start myapp from different locations, using the cwd in ecosystem.config.js and pm2 report to inspect the daemon context. Determine whether a command option or environment variable can make the daemon working directory independent of the launch location; done means the configured daemon directory remains consistent across invocation locations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100