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 <command>Sets a name for script
-i,--instances <command>Launches [number] instances (for networked app)(load balanced)
--parallel <command>Number of parallel actions (for restart/reload)
-l,--log [command]Specifies entire log file (error and out are both included)
-o,--output <command>Specifies out log file
-e,--error <command>Specifies error log file
-p,--pid <command>Specify pid file
-k,--kill-timeout <command>Delays before sending final SIGKILL signal to process
--listen-timeout <command>Listen timeout on application reload
--max-memory-restart <command>Specify max memory amount used to autorestart (in octet or use syntax like 100M)
--restart-delay <command>Specify a delay between restarts (in milliseconds)
--env <command>Specify environment to get specific env variables
--log-type <command>Specify log output style (raw by default, json optional)
-x,--execute-commandExecute a program using fork system
--max-restarts [command]Only Restart the script COUNT times
-u,--user <command>Defines user when generating startup script
--uid <command>Runs target script with <uid> rights
--gid <command>Runs target script with <gid> rights
--cwd <command>Runs target script as <username>
--hp <command>Defines home path when generating startup script
--wait-ipOverrides systemd script to wait for full internet connectivity to launch pm2
--service-name <command>Defines service name when generating startup script
-c,--cron <command>Restarts a running process based on a cron pattern
-w,--writeWrites configuration in local folder
--interpreter <command>The interpreter pm2 should use for executing app (bash, python…)
--interpreter-args <command>Interprets options (alias of –node-args)
--log-date-format <command>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 <command>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 <command...>Watches application folder for changes (default: )
–-ignore-watch <command...>Folder/files to be ignored watching
–-node-args <command>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 <command>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