I'm new to node.js and having difficulty to demonize this app using pm2.
The app works fine when I go to /srv/myapp
and run yarn start
but when I try to demonize it by going to /srv/myapp
and run pm2 start index.js
I see that the process seem to have started:
[PM2] Starting /srv/myapp/index.js in fork_mode (1 instance)
[PM2] Done.
┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
│ index │ 0 │ fork │ 14528 │ online │ 0 │ 0s │ 0% │ 16.0 MB │ root │ disabled │
└──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
Use `pm2 show <id|name>` to get more details about an app
But the front end does not respond (instead I get 502 errors
and the node server does not listen on port 3000
as expected (fuser 3000/tcp
returns no results).
What could be wrong here? How can I fix it?