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'
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.
$ 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 β
ββββββββββββ΄βββββ΄ββββββββββ΄ββββββ΄ββββββββββ΄ββββββββββ΄βββββββββ΄ββββββ΄βββββββββ΄βββββββββββ΄βββββββββββ
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-envoptions. Please note that some options will not be updated (options that are listed under General Attributes below). More documentation onβupdate-envhere[ ... ]
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
[ ... ]
Most helpful comment
Expected behavior, you need to delete the application to update the script path :
pm2 delete app && pm2 start ecosystem.config.js