A
A
AlexVWill2022-04-21 10:34:24
JavaScript
AlexVWill, 2022-04-21 10:34:24

JS does not start in daemon mode, although everything works fine in manual mode?

Subject. I have never worked with Node.JS, it took to raise a small service, and immediately the problem.
I'm trying to follow the instructions: https://www.digitalocean.com/community/tutorials/h...
I made a test "Hello, World". I put it in the /var/www/html/nodejs/server.js file . I run
the command node server.js, the inscription appears in the console

Server running at 0.0.0.0:1200
, IP_ADRESS:1200 opens "Hello World", i.e. everything works as it should.
I'm trying to daemonize the script according to the instructions, all installations pass.
I give the command: sudo pm2 start server.jsI get the following


[PM2] Applying action restartProcessId on app [server](ids: 0)
[PM2] [server](0) ✓
[PM2] Process successfully started
┌─────┬───────────── ┬─────────────┬─────────────────────┬────────── ────┬───────┬──────────────────────────────────── ──────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├──── ─┼───────────┼─────────────────────────────────────┼─── ────────┼────────┼───────┼───────────────────────┼─── ────────┼───────────┼────────────┤
│ 0 │ server │ default │ N/A │ fork │ 8303 │ 0s │ 15 │ online │ 0% │ 7.3mb │ root │ disabled │
└─────┴─────────────────────────────────────────┴──────── ──┴──────────┴────────┴────── ──┴───────────┴───────────┴─────────────────────────────────────

Everything seems to be as it should, but IP_ADRESS:1200 is unavailable.
sudo pm2 list
gives out that

┌─────┬───────────────────────────────────────────────── ──┬──────────┬─────────┬────── ──┬──────────┬──────────┬────────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status cpu │ mem │ user │ watching │
─────┼─────────┼────────────────────────────────────────── ────┼──────────┼─────────────────────────────────────┤
│ 0 │ server │ default │ N/A │ fork │ 0 │ 0 │ 30 │ errored │ 0% │ 0b │ root │ disabled │
└─────┴──────────┴── ───────────┴────────────────────────────────────────── ─┴──────┴────────────────────────────────────┴──────── ───┴───────────┘

A cursory google did not find a solution to the problem, mostly some other aspects of the work. Please suggest if anyone has an idea what might not work there.
I have not figured out the logs yet, it will be great to tell me what exactly to look for in them to understand the problem.
Thanks

spoiler
626108c6a9167479913621.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2022-04-21
@AlexVWill

Run it manually, then go to ip_adress:1200 and you will see with what error it fell. Or run pm2 log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question