• Stars
    star
    1,243
  • Rank 37,803 (Top 0.8 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automatically rotate all applications logs managed by PM2

Description

PM2 module to automatically rotate logs of processes managed by PM2.

Install

pm2 install pm2-logrotate

NOTE: the command is pm2 install NOT npm install

Configure

  • max_size (Defaults to 10M): When a file size becomes higher than this value it will rotate it (its possible that the worker check the file after it actually pass the limit) . You can specify the unit at then end: 10G, 10M, 10K
  • retain (Defaults to 30 file logs): This number is the number of rotated logs that are keep at any one time, it means that if you have retain = 7 you will have at most 7 rotated logs and your current one.
  • compress (Defaults to false): Enable compression via gzip for all rotated logs
  • dateFormat (Defaults to YYYY-MM-DD_HH-mm-ss) : Format of the data used the name the file of log
  • rotateModule (Defaults to true) : Rotate the log of pm2's module like other apps
  • workerInterval (Defaults to 30 in secs) : You can control at which interval the worker is checking the log's size (minimum is 1)
  • rotateInterval (Defaults to 0 0 * * * everyday at midnight): This cron is used to a force rotate when executed. We are using node-schedule to schedule cron, so all valid cron for node-schedule is valid cron for this option. Cron style :
  • TZ (Defaults to system time): This is the standard tz database timezone used to offset the log file saved. For instance, a value of Etc/GMT+1, with an hourly log, will save a file at hour 14 GMT with hour 13 (GMT+1) in the log name.
*    *    *    *    *    *
┬    ┬    ┬    ┬    ┬    ┬
│    │    │    │    │    |
│    │    │    │    │    └ day of week (0 - 7) (0 or 7 is Sun)
│    │    │    │    └───── month (1 - 12)
│    │    │    └────────── day of month (1 - 31)
│    │    └─────────────── hour (0 - 23)
│    └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)

How to view current configuration of the above values ?

After having installed the module, you have to type : pm2 conf

How to set these values ?

After having installed the module you have to type : pm2 set pm2-logrotate:<param> <value>

e.g:

  • pm2 set pm2-logrotate:max_size 1K (1KB)
  • pm2 set pm2-logrotate:compress true (compress logs when rotated)
  • pm2 set pm2-logrotate:rotateInterval '*/1 * * * *' (force rotate every minute)

More Repositories

1

docker-pm2

🐳 Official Docker Image for PM2 runtime
Dockerfile
476
star
2

pmx

(DEPRECATED) use @pm2/io instead (drop-in replacement) https://github.com/keymetrics/pm2-io-apm
JavaScript
265
star
3

pm2-server-monit

Monitor server CPU / Memory / Process / Zombie Process / Disk size / Security Packages / Network Input / Network Output
JavaScript
261
star
4

pm2-io-apm

PM2.io APM for Node.JS
TypeScript
147
star
5

pm2-auto-pull

This app will automatically pull all applications managed by PM2 to the latest version (compatible git)
JavaScript
136
star
6

vizion

Git/Subversion/Mercurial repository metadata parser
JavaScript
39
star
7

cli-tableau

Pretty unicode tables for the CLI with Node.JS
JavaScript
31
star
8

doc-pm2

DEPRECATED
CSS
28
star
9

pm2-io-js-api

PM2.io API Client for Javascript
JavaScript
28
star
10

pm2-plus-tech-questions

http://docs.keymetrics.io/docs/pages/faq-troubleshooting/
27
star
11

pm2-redis

Module to monitor redis
JavaScript
23
star
12

event-loop-inspector

(DEPRECATED) Dump event loop's current stats.
JavaScript
21
star
13

pm2-ebs-demo

Demo for PM2/Keymetrics integration for AWS with simple express server
JavaScript
17
star
14

app-playground

Code level metrics with Keymetrics
JavaScript
17
star
15

pm2-io-apm-go

Golang APM for PM2 Enterprise
Go
16
star
16

on-premise

Documentation for the on-premise version of PM2 Enterprise
Mustache
13
star
17

pm2-logs

Pm2 cli logs interface
JavaScript
12
star
18

pm2-elasticsearch

PM2.io Module to monitor Elasticsearch nodes
JavaScript
12
star
19

node-runtime-stats

A module that forwards stats from NodeJS runtime
C++
9
star
20

pm2-io-agent

PM2.io NodeJS Agent embed inside PM2
JavaScript
8
star
21

pm2-io-agent-node

PM2.io Agent Standalone for NodeJS
JavaScript
8
star
22

keymetrics.github.io

Keymetrics documentation website
CSS
7
star
23

interdb

👷 Local and shared database
JavaScript
6
star
24

synergy-office-control-iot

How we control our whole Paris Office with our solutions
JavaScript
5
star
25

pm2-cluster-benchmark

Benchmarking PM2 cluster vs Raw Node vs Nginx vs Haproxy
Nginx
5
star
26

keymetrics-widget

JavaScript
5
star
27

nginx-interface

Module to interface NGINX with PM2
C
5
star
28

fullstack-workshop

FullStack London 2015 - PM2 & Keymetrics workshop
JavaScript
4
star
29

install

Script to install NVM + Node + pm2 (script install.sh on app.keymetrics.io)
Shell
3
star
30

pm2-workshop

Pm2 Workshop repository
JavaScript
3
star
31

docker-interface

Node.js interface wrapper around key commands of docker and docker-compose
2
star
32

pm2-masterclass

JavaScript
2
star
33

deep-metrics

Retrieve metrics about popular modules automatically
JavaScript
2
star
34

pm2-io

SCSS
2
star
35

k8s-ansible

Ansible tasks to provision a K8S cluster
2
star
36

pm2-generate-metrics

Generate multiple graphs
JavaScript
2
star
37

branding

Keymetrics/PM2 Branding
2
star
38

pm2-io-apm-python

Python Integration for PM2.io
Python
2
star
39

trassingue

(DEPRECATED)
JavaScript
2
star
40

sample-apps

Tracing
JavaScript
1
star
41

origa

JavaScript
1
star
42

envision-sdk

🏗️ SDK to build module for Envision
JavaScript
1
star
43

envision-video

📹 Upload video for infinite replay
JavaScript
1
star
44

km_universe

JavaScript
1
star
45

pm2-tar-auto-update

JavaScript
1
star
46

tracing

1
star
47

app-showcase

JavaScript
1
star
48

simplicity

R&D blinkstick
JavaScript
1
star
49

interdb-hub

JavaScript
1
star
50

pm2-digital-signage

JavaScript
1
star
51

cpu-search

Retrieve CPU model from CPU benchmark CSV
TypeScript
1
star
52

extrareqp2

JavaScript
1
star
53

app-playground-tracing

An example app to send traces to pm2 enterprise
JavaScript
1
star
54

wakanda-hydroplant

JavaScript
1
star
55

xeon

HTML
1
star