pm2

Daemon process manager

Subcommands

NameDescription
startStarts and daemonizes an app
triggerDeploy your json
deployDeploy your json
startOrRestartStart or restart JSON file
startOrReloadStart or gracefully reload JSON file
pidReturn pid of the specified app or all
startOrGracefulReloadStart or gracefully reolad JSON file
stopStop a process
restartRestart a process
scaleScale up/down a process in cluster mode depending on the `number` param
snapshotSnapshot PM2 memory
profileProfile CPU
reloadReload processes (for apps using HTTP/HTTPS)
gracefulReloadGracefully reload a process. Send a “shutdown” message to close all connections
idGet process id by name
deleteStops and deletes a process from pm2 process list
sendSignalSend a system signal to the target process
pingPing pm2 daemon - if not it will launch up
updatePM2Update in-memory PM2 with local PM2
update(alias) update in-memory PM2 with local PM2
install, module:installInstall or update a module and run it forever
module:generateGenerate a sample module in current folder
uninstall, module:uninstallStop and uninstall a module
publish, module:publishPublish the module you are currently on
setSets the specified config
multisetMultiset eg `key1 val1 key2 val2`
getGet value for the specified key
confGet / set module config values
configGet / set module config values
unsetClears the specified config key
reportGive a full pm2 report for https://github.com/Unitech/pm2/issues
link, interactLinking action to keymetrics.io
unlinkLinking action to keymetrics.io
unmonitorUnmonitor target process
monitor<Unm>onitor target process
openOpen dashboard in browser
registerCreate an account on keymetrics
loginLogin to keymetrics and link current PM2
webLaunch a health API on 0.0.0.0:9615
dump, saveDump all processes for resurrecting them later
sendSend stdin to pm id
attachAttach stdin/stdout to application identified by pm id
resurrectResurrect previously dumped processes
unstartupDisable and clear auto startup
startupSetup script for pm2 at boot
logrotateCopy default logrotate configuration
ecosystem, initGenerate a process conf file
resetReset counters for process
describeDescribe all parameters of a process id
desc, info, show(alias) Describe all parameters of a process id
list, lsList all processes
l, ps, status(alias) list all processes
jlistList all processes in JSON format
prettylistPrint json in a prettified JSON
monitLaunch termcaps monitoring
imonitLaunch legacy termcaps monitoring
dashboard, dashLaunch dashboard with monitoring and logs
flushFlush logs
reloadLogsReload all logs
logsStream logs logs file
killKill daemon
pullUpdates repository for a given app
forwardUpdates repository to the next commit for a given app
backwardDowngrades repository to the previous commit for a given app
gcForce PM2 to trigger garbage collection
deepUpdatePerforms a deep update of PM2
serve, exposeServes a directory over http via port

Options

NameDescription
-V, --versionOutputs the version number
-vGets version
-s, --silentHides all messages
-m, --mini-listDisplays a compacted list without formatting
-f, --forceForces actions
--disable-logsDo not write logs
-n, --name <name>Sets a name for script
-i, --instances <number>Launches [number] instances (for networked app)(load balanced)
--parallel <number>Number of parallel actions (for restart/reload)
-l, --log [path]Specifies entire log file (error and out are both included)
-o, --output <path>Specifies out log file
-e, --error <path>Specifies error log file
-p, --pid <pid>Specify pid file
-k, --kill-timeout <delay>Delays before sending final SIGKILL signal to process
--listen-timeout <delay>Listen timeout on application reload
--max-memory-restart <memory>Specify max memory amount used to autorestart (in octet or use syntax like 100M)
--restart-delay <delay>Specify a delay between restarts (in milliseconds)
--env <Environment Name>Specify environment to get specific env variables
--log-type <type>Specify log output style (raw by default, json optional)
-x, --execute-commandExecute a program using fork system
--max-restarts [Count]Only Restart the script COUNT times
-u, --user <username>Defines user when generating startup script
--uid <uid>Runs target script with <uid> rights
--gid <gid>Runs target script with <gid> rights
--cwd <path>Runs target script as <username>
--hp <home path>Defines home path when generating startup script
--wait-ipOverrides systemd script to wait for full internet connectivity to launch pm2
--service-name <name>Defines service name when generating startup script
-c, --cron <Cron Pattern>Restarts a running process based on a cron pattern
-w, --writeWrites configuration in local folder
--interpreter <interpreter>The interpreter pm2 should use for executing app (bash, python…)
--interpreter-args <Arguments>Interprets options (alias of –node-args)
--log-date-format <Date Format>Adds custom prefix timestamp to logs
--no-daemonRuns pm2 daemon in the foreground if it doesn’t exist already
-a, --update-envUpdates environment on restart/reload (-a <=> apply)
–-source-map-supportForce source map support
–-only <app name>With json declaration, allow to only act on one application
–-disable-source-map-supportForce source map support
–-wait-readyAsks pm2 to wait for ready event from your app
–-merge-logsMerges logs from different instances but keep error and out separated
–-watch <paths...>Watches application folder for changes (default: )
–-ignore-watch <Folder or Files...>Folder/files to be ignored watching
–-node-args <Node Args>Space delimited arguments to pass to node in cluster mode
–-no-colorSkip colors
–-no-vizionStarts an app without vizion feature (versioning control)
–-no-autorestartStarts an app without automatic restart
–-no-treekillOnly kills the main process, not detached children
–-no-pmxStarts an app without apm
–-no-automationStarts an app without apm
–-traceEnables transaction tracing with km
–-disable-traceDisables transaction tracing with km
–-attachAttaches logging after your start/restart/stop/reload
–-sort <field name>Sort process according to field’s name
–-v8Enables v8 data collecting
–-event-loop-inspectorEnables event-loop-inspector dump in apm
–-deep-monitoringEnables all monitoring tools (equivalent to –v8 –event-loop-inspector –trace)
-h, –-helpOutputs usage information