Unitech / Unitech/pm2

log filenames are prefixed with dash

Open
#5,355 0 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

What's going wrong?

I just logged into our server to read our logs and found this:

-rw-rw-r-- 1 services services 184K Mar  4 12:33 server-error.log
-rw-rw-r-- 1 services services 3.5M Mar  4 15:18 server-out.log
-rw-rw-r-- 1 services services  73K Apr 21 23:20 -services-error.log
-rw-rw-r-- 1 services services 1.2M Apr 29 06:08 -services-out.log

I find it quit impossible to do anything with a file when the name begins with a -.

For example:

tail -services-error.log
tail: invalid number of seconds: ‘ervices-error.log’

the same for mv, cp, etc.

How could we reproduce this issue?

I suspect that it has to do with our app name, @services.

pm2 status
┌─────┬──────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name         │ namespace   │ version │ mode    │ pid      │ uptime │ ↺   │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼──────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ @services    │ default     │ 2.0.0   │ fork    │ 794      │ 31h    │ 0    │ online    │ 0%       │ 51.2mb   │ services │ enabled  │
└─────┴──────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

If it's the app name, then a possible solution could be to either, to disallow app names that are unsuitable as file names or make sure characters that are unsuitable, are not the first character in a file name.

Supporting information

$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date                 : Sat Apr 30 2022 14:11:53 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.2.0
node version         : 16.14.2
node path            : not found
argv                 : /usr/local/bin/node,/usr/local/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : services
uid                  : 1000
gid                  : 1000
uptime               : 1923min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 5.2.0
node version         : 16.14.2
node path            : /usr/local/bin/pm2
argv                 : /usr/local/bin/node,/usr/local/bin/pm2,report
argv0                : node
user                 : services
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
cpus nb              : 2
freemem              : 624553984
totalmem             : 1024069632
home                 : /home/services
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬──────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name         │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼──────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ @services    │ default     │ 2.0.0   │ fork    │ 794      │ 32h    │ 0    │ online    │ 0.2%     │ 50.6mb   │ services │ enabled  │
└─────┴──────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/services/.pm2/pm2.log last 20 lines:
PM2        | 2022-04-29T06:05:38: PM2 log: PM2 successfully stopped
PM2        | 2022-04-29T06:08:27: PM2 log: ===============================================================================
PM2        | 2022-04-29T06:08:27: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | 2022-04-29T06:08:27: PM2 log: Time                 : Fri Apr 29 2022 06:08:27 GMT+0000 (Coordinated Universal Time)
PM2        | 2022-04-29T06:08:27: PM2 log: PM2 version          : 5.2.0
PM2        | 2022-04-29T06:08:27: PM2 log: Node.js version      : 16.14.2
PM2        | 2022-04-29T06:08:27: PM2 log: Current arch         : x64
PM2        | 2022-04-29T06:08:27: PM2 log: PM2 home             : /home/services/.pm2
PM2        | 2022-04-29T06:08:27: PM2 log: PM2 PID file         : /home/services/.pm2/pm2.pid
PM2        | 2022-04-29T06:08:27: PM2 log: RPC socket file      : /home/services/.pm2/rpc.sock
PM2        | 2022-04-29T06:08:27: PM2 log: BUS socket file      : /home/services/.pm2/pub.sock
PM2        | 2022-04-29T06:08:27: PM2 log: Application log path : /home/services/.pm2/logs
PM2        | 2022-04-29T06:08:27: PM2 log: Worker Interval      : 30000
PM2        | 2022-04-29T06:08:27: PM2 log: Process dump file    : /home/services/.pm2/dump.pm2
PM2        | 2022-04-29T06:08:27: PM2 log: Concurrent actions   : 2
PM2        | 2022-04-29T06:08:27: PM2 log: SIGTERM timeout      : 1600
PM2        | 2022-04-29T06:08:27: PM2 log: ===============================================================================
PM2        | 2022-04-29T06:08:27: PM2 log: [Watch] Start watching @services
PM2        | 2022-04-29T06:08:27: PM2 log: App [@services:0] starting in -fork mode-
PM2        | 2022-04-29T06:08:27: PM2 log: App [@services:0] online

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

No source file or test is named. Start by tracing how PM2 constructs application log filenames for the @services app, reproduce the case from the issue, and verify that generated log paths no longer begin with a dash while normal app names continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.