I have a node app with forever-monitor.
When I run it locally it works correctly.
When I run it manually on a digitalocean droplet with node app-fm.js
it also run correctly.
However, when It tries to start with pm2 it get error-ed.
Checking the pm2 logs I see:
/root/.pm2/logs/app-fm-out.log last 15 lines:
/root/.pm2/logs/app-fm-error.log last 15 lines:
0|app-fm | Error: Target script does not exist: app.js
0|app-fm | at /root/wa-bot/node_modules/forever-monitor/lib/forever-monitor/monitor.js:170:9
0|app-fm | at processTicksAndRejections (node:internal/process/task_queues:78:11)
app-fm.js is the entry file (the app run with node app-fm.js
)
app.js is invoked as follow:
var forever = require('forever-monitor')
const fm = new(forever.Monitor)('app.js', {
max: 1,
silent: false,
})
Both the files (app-fm.js
and app.js
) are in the root folder of the project.
The project on digitalocean is in /root/wa-bot
folder
I resolved it with:
const fm = new(forever.Monitor)('app.js', {
max: 1,
silent: false,
sourceDir: (!process.env.DESKTOP_SESSION) ? '/root/wa-bot/' : null
})
For some reason on the digitalocean droplet (running ubuntu 20.04) the sourceDir
is required while on my ubuntu 20.04 laptop is not.