Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

pm2

# Monitoring CPU/Memory
pm2 monit
pm2 monitor
Make pm2 auto-boot at server restart:
pm2 startup
# Go To Server Directory Where you have store Express Files 
pm2 start app.js -o "/dev/null" -e "/dev/null"
# Freeze your process list across server restart
3.pm2 save
# Auto restart apps on file change
4. pm2 start app.js --watch
# Remove init script via:
$ pm2 unstartup systemd
Comment

pm2

// To start npm with pm2 for nextjs just type
pm2 start npm --name "APP_NAME" -- start
Comment

pm2

import pm2 from 'pm2'
import os from 'os'

pm2.connect((err: Error) => {
  if (!err) {
    pm2.start(
      {
        name: 'express-rest-api',
        script: 'dist/main.js',
        watch: false,
        env: { NODE_ENV: 'production', NODE_OPTIONS: '--max_old_space_size=32768' },
        exec_mode: 'cluster',
        instances: os.cpus().length,
        max_memory_restart: '512M',
        kill_timeout: 6000
      },
      (err: Error, _proc: pm2.Proc) => {
        if (err) {
          pm2.restart('express-rest-api', (err: Error, _proc: pm2.Proc) => {
            if (!err) return pm2.disconnect()
          })
        }
      }
    )
  }
})
Comment

PM2

$ npm install pm2@latest -g
Comment

pm2

pm2 monit
Comment

PM2

PM2 Installation 

$ npm install pm2@latest -g

starting node app using pm2
$ pm2 start app.js

other CMDs

# Specify an app name
--name <app_name>

# Watch and Restart app when files change
--watch

# Set memory threshold for app reload
--max-memory-restart <200MB>

# Specify log file
--log <log_path>

# Pass extra arguments to the script
-- arg1 arg2 arg3

# Delay between automatic restarts
--restart-delay <delay in ms>

# Prefix logs with time
--time

# Do not auto restart app
--no-autorestart

# Specify cron for forced restart
--cron <cron_pattern>

# Attach to application log
--no-daemon
# Starting python app
$ pm2 start job1.py --name job1 --interpreter python3
Comment

PREVIOUS NEXT
Code Example
Shell :: yes/no 
Shell :: yes no 
Shell :: centos remote desktop 
Shell :: git log get out hotkey 
Shell :: install openvpn acces 2.5.2 
Shell :: how to convert a multy digit array into a whole number 
Shell :: Private DNS EC2 BASH 
Shell :: dos search include subdirectories 
Shell :: change hostname rhel 6 
Shell :: mac cleanup github 
Shell :: github extension for solidity language 
Shell :: disable monitor on boot linux 
Shell :: verify in core compressor with swap backend VM_PAGER_COMPRESSOR_WITH_SWAP 
Shell :: ubuntu install apache mod_version 
Shell :: You must specify at least one graphical backend feature: "metal", "vulkan", "empty" 
Shell :: multipass no space left on device 
Shell :: where is /snap directory manjaro 
Shell :: youtube-dl Network Options 
Shell :: setting and changing a project 
Shell :: heroku cli container select context folder 
Shell :: repeat characters for line vim 
Shell :: put all folders with specific name in git ignore 
Shell :: ubuntu show current path 
Shell :: how to open powershell in current directory shortcut 
Shell :: test wifi password 
Shell :: screen set env variables 
Shell :: fix commit on wrong branch 
Shell :: Dokument mit Datum speichern Powershell 
Shell :: linux set permissions for all files matching pattern 
Shell :: git checkout specific file types 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =