Pm2: Wrong CWD using pm2-runtime

Created on 9 Jan 2020  ยท  9Comments  ยท  Source: Unitech/pm2

What's going wrong?

When using pm2-runtime process.yml current working directory passed to NodeJS script become: ./process.yml/ as a "directory parameters" or somethings similar.

Set "cwd" app's option configuration in process.yml does not made any difference, seems completely ignored.

How could we reproduce this issue?

I follow Docker guide and created a process.yml file:

apps:
  - script: ./node_modules/nuxt-start/bin/nuxt-start.js
    name: 'app'
    instances: 'max'
    exec_mode: cluster
    env: 
      NODE_ENV: 'production'

then set Docker entrypoint to /usr/bin/pm2-runtime process.yml (guide suggest to use CMD ["pm2-runtime", "process.yml"] that has the same effect) and Nuxt fail during start-up:

Error: No build files found in /app/process.yml/.nuxt/dist/server. 

my app reside in /app (as volume), so you can notice the wrong CWD "/app/process.yml/" passed to script.

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Thu Jan 09 2020 16:52:39 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.2.1
node version         : 10.17.0
node path            : not found
argv                 : /usr/bin/node,/usr/bin/pm2-runtime,process.yml,--only,app
argv0                : node
user                 : undefined
uid                  : 0
gid                  : 0
uptime               : 0min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.2.1
node version         : 10.17.0
node path            : not found
argv                 : /usr/bin/node,/usr/bin/pm2,report
argv0                : node
user                 : undefined
uid                  : 0
gid                  : 0
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
cpus nb              : 8
freemem              : 253816832
totalmem             : 16698138624
home                 : /root
===============================================================================
--- PM2 list -----------------------------------------------
โ”Œโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ id โ”‚ name               โ”‚ mode     โ”‚ โ†บ    โ”‚ status    โ”‚ cpu      โ”‚ memory   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 0  โ”‚ app                โ”‚ cluster  โ”‚ 5    โ”‚ online    โ”‚ 0%       โ”‚ 35.1mb   โ”‚
โ”‚ 1  โ”‚ app                โ”‚ cluster  โ”‚ 5    โ”‚ launching โ”‚ 0%       โ”‚ 0b       โ”‚
โ”‚ 2  โ”‚ app                โ”‚ cluster  โ”‚ 4    โ”‚ online    โ”‚ 58.2%    โ”‚ 60.9mb   โ”‚
โ”‚ 3  โ”‚ app                โ”‚ cluster  โ”‚ 4    โ”‚ online    โ”‚ 0%       โ”‚ 50.8mb   โ”‚
โ”‚ 4  โ”‚ app                โ”‚ cluster  โ”‚ 4    โ”‚ online    โ”‚ 0%       โ”‚ 50.7mb   โ”‚
โ”‚ 5  โ”‚ app                โ”‚ cluster  โ”‚ 4    โ”‚ online    โ”‚ 0%       โ”‚ 43.2mb   โ”‚
โ”‚ 6  โ”‚ app                โ”‚ cluster  โ”‚ 4    โ”‚ online    โ”‚ 0%       โ”‚ 39.8mb   โ”‚
โ”‚ 7  โ”‚ app                โ”‚ cluster  โ”‚ 4    โ”‚ launching โ”‚ 0%       โ”‚ 0b       โ”‚
โ””โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
===============================================================================
--- Daemon logs --------------------------------------------
stale

Most helpful comment

Same error using pm2-runtime start ecosystem.config.js:

Error: No build files found in /app/ecosystem.config.js/.nuxt/dist/server

All 9 comments

Same error using pm2-runtime start ecosystem.config.js:

Error: No build files found in /app/ecosystem.config.js/.nuxt/dist/server

any updates on this issue ?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

And again FATAL No build files found in /docker-.../pm.config.js/.nuxt/dist/server

I have same issue @jsjain, Did you find any solution?

giving the cwd, fixed it for me

@jsjain cwd in ecosystem file ? can you give an example ?

yeah sure, cwd: '/user/src/app' assuming this is where your code is. and along with it script will still be the same script: ./node_modules/nuxt-start/bin/nuxt-start.js

thanks @jsjain, but finally I changed my script in ecosystem, because our app is working in workspace and I don't want to setup fixed path to cwd so it looks now:

  script: './node_modules/nuxt/bin/nuxt.js',
  args: `-c ${join(__dirname, 'packages/your-app/nuxt.config.js')}`,

additionally you have to change rootDir in nuxt.config

rootDir: __dirname,

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajendar38 picture rajendar38  ยท  3Comments

getvega picture getvega  ยท  3Comments

cchan picture cchan  ยท  3Comments

webchaz picture webchaz  ยท  3Comments

shaunwarman picture shaunwarman  ยท  3Comments