I have a simple pm2
config containing some app's;
{
name: "App1",
script: "/home/scripts/websockets/app1-websocket.js",
instances: 1,
log_date_format: "YYYY-MM-DD HH:mm",
out_file : "/dev/null",
restart_delay : 30000,
max_restarts : 5,
exp_backoff_restart_delay: 500,
namespace: "APPS",
},
{
name: "App2",
script: "/home/scripts/websockets/app2-websocket.js",
instances: 1,
log_date_format: "YYYY-MM-DD HH:mm",
out_file : "/dev/null",
restart_delay : 30000,
max_restarts : 5,
exp_backoff_restart_delay: 500,
namespace: "APPS",
}
This is all local files and I'm not looking to bundle them into git or similar for such a small project. I'd like to know if there is a way to manually set the version
meta-data field shown in pm2 ls
as that way we can still set & track what's running.
Current:
│ 0 │ App1 │ APPS │ N/A │ fork │ 1234 │ 7m │ 0 │ online │ 0% │ 33.2mb │ lusr │ disabled │
│ 1 │ App2 │ APPS │ N/A │ fork │ 1235 │ 14h │ 0 │ online │ 0% │ 9.4mb │ lusr │ disabled │
Desired:
│ 0 │ App1 │ APPS │ 3.1.2 │ fork │ 1234 │ 7m │ 0 │ online │ 0% │ 33.2mb │ lusr │ disabled │
│ 1 │ App2 │ APPS │ 2.1.0 │ fork │ 1235 │ 14h │ 0 │ online │ 0% │ 9.4mb │ lusr │ disabled │
After much being distracted with packaging app's and all that other stuff it's not actually needed for most basic setup and I wish the doc's where more clear.
All you need to do is put the script or app you are executing into it's own directory along with a file called package.json
and update the config with the new path. It doesn't matter what the thing is your running from pm2
long as it's in it's own folder;
{
name: "App1",
script: "/home/scripts/websockets/app1/app1-websocket.js",
instances: 1,
log_date_format: "YYYY-MM-DD HH:mm",
out_file : "/dev/null",
restart_delay : 30000,
max_restarts : 5,
exp_backoff_restart_delay: 500,
namespace: "APPS",
},
Then in /home/scripts/websockets/app1/
we have the app1.js
& package.json
files.
Inside the package.json
all you need to specify is;
{
"name" : "App1",
"version" : "1.1.0",
"description": "App Scripts"
}
Then delete and reload the process with pm2 delete 0
pm2 start config.js --only app1
pm2 info App1
version │ 1.1.0
Now it shows my desired version number... BUT REMEMBER... As this is linked to a static file you will need to manually update the package.json
file with any changes to the version number.