Pm2: reload/refresh don't update script file path

Created on 29 Jul 2017  Β·  2Comments  Β·  Source: Unitech/pm2

What's going wrong?

Here's my configuration file:

apps:
  - name: app
    script: dist/app.js
    instances: 0
    exec_mode: cluster
    combine_logs: true
    source_map_support: true

I'm performing in-place deployments, so I sometimes need to reload the configuration file.

The issue is that the instances come with a default application, with a slightly different configuration file:

apps:
  - name: app
    script: index.js # <------------ HERE
    instances: 0
    exec_mode: cluster
    combine_logs: true
    source_map_support: true

However, when I deploy de real application, I keep getting this error:

Error: Cannot find module '/var/app/current/index.js'

How could we reproduce this issue?

I've tried the following:

pm2 restart ecosystem.config.yml
pm2 reload ecosystem.config.yml
pm2 startOrReload ecosystem.config.yml
pm2 restart ecosystem.config.yml --update-env
pm2 reload ecosystem.config.yml --update-env
pm2 startOrReload ecosystem.config.yml --update-env

All failed.

Supporting information

$ pm2 --version
3.10.10

$ pm2 report

===============================================================================
--- PM2 REPORT (Sat Jul 29 2017 03:34:58 GMT+0000 (UTC)) ----------------------
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 2.6.1
node version         : 6.11.1
node path            : /var/app/current/node_modules/pm2/bin/pm2
argv                 : /home/ec2-user/n/bin/node,/var/app/current/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : ec2-user
uid                  : 500
gid                  : 500
uptime               : 9min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 2.6.1
node version         : 6.11.1
node path            : /var/app/current/node_modules/.bin/pm2
argv                 : /home/ec2-user/n/bin/node,/var/app/current/node_modules/.bin/pm2,report
argv0                : node
user                 : ec2-user
uid                  : 500
gid                  : 500
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
cpus nb              : 1
freemem              : 144711680
totalmem             : 1041788928
home                 : /home/ec2-user
===============================================================================
--- PM2 list -----------------------------------------------
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ App name β”‚ id β”‚ mode    β”‚ pid β”‚ status  β”‚ restart β”‚ uptime β”‚ cpu β”‚ mem    β”‚ user     β”‚ watching β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ app      β”‚ 0  β”‚ cluster β”‚ 0   β”‚ errored β”‚ 106     β”‚ 0      β”‚ 0%  β”‚ 0 B    β”‚ ec2-user β”‚ disabled β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
===============================================================================
--- Daemon logs --------------------------------------------
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ App name β”‚ id β”‚ mode    β”‚ pid β”‚ status  β”‚ restart β”‚ uptime β”‚ cpu β”‚ mem    β”‚ user     β”‚ watching β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ app      β”‚ 0  β”‚ cluster β”‚ 0   β”‚ errored β”‚ 106     β”‚ 0      β”‚ 0%  β”‚ 0 B    β”‚ ec2-user β”‚ disabled β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Most helpful comment

Expected behavior, you need to delete the application to update the script path : pm2 delete app && pm2 start ecosystem.config.js

All 2 comments

Expected behavior, you need to delete the application to update the script path : pm2 delete app && pm2 start ecosystem.config.js

@vmarchaud , I found that information in the docs right after I posted the issue. Sorry about that.

For those who might be interested, here are the relevant parts:

Updating running conf

Starting PM2 v2.1.X, environments are immutable by default, that means the environment will never be updated unless you tell PM2 to do so, to update configurations, you will need to use --update-env options. Please note that some options will not be updated (options that are listed under General Attributes below). More documentation on –update-env here

[ ... ]

Attributes available

General

Field | Type | Example | Description
-- | -- | -- | --
name | (string) | β€œmy-api” | application name (default to script filename without extension)
script | (string) | ”./api/app.js” | script path relative to pm2 start
[ ... ]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shaunwarman picture shaunwarman  Β·  3Comments

psparago picture psparago  Β·  3Comments

liujb picture liujb  Β·  3Comments

ldarren picture ldarren  Β·  3Comments

lefam picture lefam  Β·  3Comments