Unitech / Unitech/pm2

== HELP == status errored

Open
#5,806 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

fails to start

If you run it manually via = node server.js = everything works.

How could we reproduce this issue?

server.js

const express = require('express')

const traccar = require('./controllers/traccar');

const app = express()
const port = process.env.PORT || 8081;

require('dotenv').config();

const helmet = require('helmet')
app.use(helmet())

// Traccar app
app.post('/', traccar);

app.listen(port, () => console.log(Traccar Application to Thingsboard gateway running on port ${port}!))

Supporting information

# Run the following commands
$ pm2 report

● pm2-kto.service - PM2 process manager
Loaded: loaded (/etc/systemd/system/pm2-kto.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2024-04-20 10:01:19 CEST; 5min ago
Docs: https://pm2.keymetrics.io/
Process: 772 ExecStart=/usr/local/lib/node_modules/pm2/bin/pm2 resurrect (code=exited, status=0/SUCCESS)
Main PID: 946 (PM2 v5.3.1: God)
Tasks: 11 (limit: 2219)
Memory: 71.2M
CPU: 12.286s
CGroup: /system.slice/pm2-kto.service
└─946 "PM2 v5.3.1: God Daemon (/home/kto/.pm2)" "" "" "" "" "" "" "" "" "" "" ""

Apr 20 10:01:19 gps-traccar pm2[772]: [PM2] PM2 Successfully daemonized
Apr 20 10:01:19 gps-traccar pm2[772]: [PM2] Resurrecting
Apr 20 10:01:19 gps-traccar pm2[772]: [PM2] Restoring processes located in /home/kto/.pm2/dump.pm2
Apr 20 10:01:19 gps-traccar pm2[772]: [PM2] Process /home/kto/tb-traccar-connector/server.js restored
Apr 20 10:01:19 gps-traccar pm2[772]: ┌────┬───────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
Apr 20 10:01:19 gps-traccar pm2[772]: │ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
Apr 20 10:01:19 gps-traccar pm2[772]: ├────┼───────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
Apr 20 10:01:19 gps-traccar pm2[772]: │ 0 │ server │ default │ 0.0.1 │ fork │ 962 │ 0s │ 0 │ online │ 0% │ 34.6mb │ kto │ disabled │
Apr 20 10:01:19 gps-traccar pm2[772]: └────┴───────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
Apr 20 10:01:19 gps-traccar systemd[1]: Started PM2 process manager.
=========:~$ pm2 report

--- PM2 report ----------------------------------------------------------------
Date                 : Sat Apr 20 2024 10:07:10 GMT+0200 (Central European Summer Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.3.1
node version         : 12.22.9
node path            : not found
argv                 : /usr/bin/node,/usr/local/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : kto
uid                  : 1000
gid                  : 1000
uptime               : 5min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 5.3.1
node version         : 12.22.9
node path            : /usr/local/bin/pm2
argv                 : /usr/bin/node,/usr/local/bin/pm2,report
argv0                : node
user                 : kto
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
cpus nb              : 4
freemem              : 1647108096
totalmem             : 2058579968
home                 : /home/kto
===============================================================================
--- PM2 list -----------------------------------------------
┌────┬───────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name      │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├────┼───────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0  │ server    │ default     │ 0.0.1   │ fork    │ 0        │ 0      │ 15   │ errored   │ 0%       │ 0b       │ kto      │ disabled │
└────┴───────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/kto/.pm2/pm2.log last 20 lines:
PM2        | 2024-04-20T10:01:24: PM2 log: App [server:0] exited with code [1] via signal [SIGINT]
PM2        | 2024-04-20T10:01:24: PM2 log: App [server:0] starting in -fork mode-
PM2        | 2024-04-20T10:01:24: PM2 log: App [server:0] online
PM2        | 2024-04-20T10:01:25: PM2 log: App [server:0] exited with code [1] via signal [SIGINT]
PM2        | 2024-04-20T10:01:25: PM2 log: App [server:0] starting in -fork mode-
PM2        | 2024-04-20T10:01:25: PM2 log: App [server:0] online
PM2        | 2024-04-20T10:01:25: PM2 log: App [server:0] exited with code [1] via signal [SIGINT]
PM2        | 2024-04-20T10:01:25: PM2 log: App [server:0] starting in -fork mode-
PM2        | 2024-04-20T10:01:25: PM2 log: App [server:0] online
PM2        | 2024-04-20T10:01:26: PM2 log: App [server:0] exited with code [1] via signal [SIGINT]
PM2        | 2024-04-20T10:01:26: PM2 log: App [server:0] starting in -fork mode-
PM2        | 2024-04-20T10:01:26: PM2 log: App [server:0] online
PM2        | 2024-04-20T10:01:27: PM2 log: App [server:0] exited with code [1] via signal [SIGINT]
PM2        | 2024-04-20T10:01:27: PM2 log: App [server:0] starting in -fork mode-
PM2        | 2024-04-20T10:01:27: PM2 log: App [server:0] online
PM2        | 2024-04-20T10:01:27: PM2 log: App [server:0] exited with code [1] via signal [SIGINT]
PM2        | 2024-04-20T10:01:27: PM2 log: App [server:0] starting in -fork mode-
PM2        | 2024-04-20T10:01:27: PM2 log: App [server:0] online
PM2        | 2024-04-20T10:01:28: PM2 log: App [server:0] exited with code [1] via signal [SIGINT]
PM2        | 2024-04-20T10:01:28: PM2 log: Script /home/kto/tb-traccar-connector/server.js had too many unstable restarts (16). Stopped. "errored"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with server.js and compare running it directly with the PM2-resurrected process. Inspect the PM2 report and daemon logs, including the repeated exit code 1 and unstable-restart messages, to identify why the process behaves differently. Done means the cause is reproduced and server.js starts reliably under PM2.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.