5 local -a _1st_arguments
8 "start:start and daemonize an app"
9 "trigger:trigger process action"
10 "deploy:deploy your json"
11 "startOrRestart:start or restart JSON file"
12 "startOrReload:start or gracefully reload JSON file"
13 "pid:return pid of [app_name] or all"
15 "restart:restart a process"
16 "scale:scale up/down a process in cluster mode depending on total_number param"
17 "profile\:mem:Sample PM2 heap memory"
18 "profile\:cpu:Profile PM2 cpu"
19 "reload:reload processes (note that its for app using HTTP/HTTPS)"
20 "id:get process id by name"
21 "inspect:inspect a process"
22 "delete:stop and delete a process from pm2 process list"
23 "sendSignal:send a system signal to the target process"
24 "ping:ping pm2 daemon - if not up it will launch it"
25 "updatePM2:update in-memory PM2 with local PM2"
26 "install:install or update a module and run it forever"
27 "module\:update:update a module and run it forever"
28 "module\:generate:Generate a sample module in current folder"
29 "uninstall:stop and uninstall a module"
30 "package:Check & Package TAR type module"
31 "publish:Publish the module you are currently on"
32 "set:sets the specified config <key> <value>"
33 "multiset:multiset eg \"key1 val1 key2 val2\""
34 "get:get value for <key>"
35 "config:get / set module config values"
36 "unset:clears the specified config <key>"
37 "report:give a full pm2 report for https\://github.com/Unitech/pm2/issues"
38 "link:link with the pm2 monitoring dashboard"
39 "unlink:unlink with the pm2 monitoring dashboard"
40 "monitor:monitor target process"
41 "unmonitor:unmonitor target process"
42 "open:open the pm2 monitoring dashboard"
43 "plus:enable pm2 plus"
44 "login:Login to pm2 plus"
45 "logout:Logout from pm2 plus"
46 "web:launch a health API on 0.0.0.0\:9615"
47 "dump:dump all processes for resurrecting them later"
48 "cleardump:Create empty dump file"
49 "send:send stdin to <pm_id>"
50 "attach:attach stdin/stdout to application identified by <pm_id>"
51 "resurrect:resurrect previously dumped processes"
52 "unstartup:disable the pm2 startup hook"
53 "startup:enable the pm2 startup hook"
54 "logrotate:copy default logrotate configuration"
55 "ecosystem:generate a process conf file. (mode = null or simple)"
56 "reset:reset counters for process"
57 "describe:describe all parameters of a process id"
58 "list:list all processes"
59 "jlist:list all processes in JSON format"
60 "prettylist:print json in a prettified JSON"
61 "monit:launch termcaps monitoring"
62 "imonit:launch legacy termcaps monitoring"
63 "dashboard:launch dashboard with monitoring and logs"
65 "reloadLogs:reload all logs"
66 "logs:stream logs file. Default stream all logs"
68 "pull:updates repository for a given app"
69 "forward:updates repository to the next commit for a given app"
70 "backward:downgrades repository to the previous commit for a given app"
71 "deepUpdate:performs a deep update of PM2"
72 "serve:serve a directory over http via port"
73 "examples:display pm2 usage examples"
80 app_list=`pm2 list -m`
83 names=(`echo $app_list | grep '+---' | awk '{print $2}'`)
84 ids=(`echo $app_list | grep 'pm2 id' | awk '{print $4}'`)
86 if (( ${#ids} > 0 )); then
87 for i in {1..${#ids}}; do
88 id_names+=( "${ids[i]}:${names[i]}" )
94 '(-v --version)'{-v,--version}'[output version]' \
95 '(-h --help)'{-h,--help}'[output usage information]' \
96 '*:: :->subcmds' && return 0
98 if (( CURRENT == 1 )); then
99 _describe "command" _1st_arguments
103 local -a id_comp id_all_comp id_all_files_comp start_options logs_options
104 id_comp=('1: :->id_comp')
105 id_all_comp=('1: :->id_all_comp')
106 id_all_files_comp=('1: :->id_all_files_comp')
108 '--watch[Watch folder for changes]'
109 '--fresh[Rebuild Dockerfile]'
110 '--daemon[Run container in Daemon mode (debug purposes)]'
111 '--container[Start application in container mode]'
112 '--dist[with --container; change local Dockerfile to containerize all files in current directory]'
113 '--image-name[with --dist; set the exported image name]'
114 '--node-version[with --container, set a specific major Node.js version]'
115 '--dockerdaemon[for debugging purpose]'
116 '(-h --help)'{-h,--help}'[output usage information]'
120 '--json[json log output]'
121 '--format[formatted log output]'
123 '--err[only shows error output]'
124 '--out[only shows standard output]'
125 '--lines[output the last N lines, instead of the last 15 by default]'
126 '--timestamp[add timestamps (default format YYYY-MM-DD-HH:mm:ss)]'
127 '--nostream[print logs without launching the log stream]'
128 '(-h --help)'{-h,--help}'[output usage information]'
134 _arguments $start_options && return 0
137 _arguments $logs_options && return 0
139 stop|restart|delete|reload|reset)
140 _arguments $id_all_comp && return 0
142 env|inspect|monitor|unmonitor|describe)
143 _arguments $id_comp && return 0
145 deploy|startOrRestart|startOrReload)
153 'args:app args:(($id_names))'
159 'args:app args:(($id_names))'
165 'args:app args:(($id_names))' \
166 'files:filename:_files'