@ohos-ports/pm2 0.0.0-stage → 7.1.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/CHANGELOG.md +2607 -0
  2. package/CONTRIBUTING.md +124 -0
  3. package/GNU-AGPL-3.0.txt +665 -0
  4. package/LICENSE +1 -0
  5. package/README.md +255 -2
  6. package/SECURITY.md +41 -0
  7. package/bin/pm2 +3 -0
  8. package/bin/pm2-dev +3 -0
  9. package/bin/pm2-docker +3 -0
  10. package/bin/pm2-runtime +3 -0
  11. package/bin/pm2.ps1 +3 -0
  12. package/constants.js +113 -0
  13. package/index.js +12 -0
  14. package/lib/API/Configuration.js +212 -0
  15. package/lib/API/Containerizer.js +335 -0
  16. package/lib/API/Dashboard.js +726 -0
  17. package/lib/API/Deploy.js +117 -0
  18. package/lib/API/Extra.js +798 -0
  19. package/lib/API/ExtraMgmt/Docker.js +30 -0
  20. package/lib/API/Log.js +388 -0
  21. package/lib/API/LogManagement.js +351 -0
  22. package/lib/API/Modules/LOCAL.js +122 -0
  23. package/lib/API/Modules/Modularizer.js +148 -0
  24. package/lib/API/Modules/NPM.js +443 -0
  25. package/lib/API/Modules/TAR.js +368 -0
  26. package/lib/API/Modules/flagExt.js +46 -0
  27. package/lib/API/Modules/index.js +120 -0
  28. package/lib/API/Monit.js +247 -0
  29. package/lib/API/Serve.js +497 -0
  30. package/lib/API/Startup.js +630 -0
  31. package/lib/API/UX/helpers.js +213 -0
  32. package/lib/API/UX/index.js +9 -0
  33. package/lib/API/UX/pm2-describe.js +197 -0
  34. package/lib/API/UX/pm2-ls-minimal.js +31 -0
  35. package/lib/API/UX/pm2-ls.js +581 -0
  36. package/lib/API/Version.js +383 -0
  37. package/lib/API/interpreter.json +12 -0
  38. package/lib/API/pm2-plus/PM2IO.js +381 -0
  39. package/lib/API/pm2-plus/auth-strategies/CliAuth.js +306 -0
  40. package/lib/API/pm2-plus/auth-strategies/WebAuth.js +195 -0
  41. package/lib/API/pm2-plus/helpers.js +97 -0
  42. package/lib/API/pm2-plus/link.js +126 -0
  43. package/lib/API/pm2-plus/pres/motd +16 -0
  44. package/lib/API/pm2-plus/pres/motd.update +26 -0
  45. package/lib/API/pm2-plus/pres/welcome +28 -0
  46. package/lib/API/pm2-plus/process-selector.js +52 -0
  47. package/lib/API/schema.json +375 -0
  48. package/lib/API.js +1980 -0
  49. package/lib/Client.js +793 -0
  50. package/lib/Common.js +949 -0
  51. package/lib/Configuration.js +309 -0
  52. package/lib/Daemon.js +468 -0
  53. package/lib/Event.js +37 -0
  54. package/lib/God/ActionMethods.js +955 -0
  55. package/lib/God/ClusterMode.js +192 -0
  56. package/lib/God/ForkMode.js +205 -0
  57. package/lib/God/Methods.js +292 -0
  58. package/lib/God/Reload.js +300 -0
  59. package/lib/God/StdioLogger.js +239 -0
  60. package/lib/God.js +653 -0
  61. package/lib/HttpInterface.js +75 -0
  62. package/lib/OtelManager.js +74 -0
  63. package/lib/ProcessContainer.js +321 -0
  64. package/lib/ProcessContainerBun.js +355 -0
  65. package/lib/ProcessContainerFork.js +42 -0
  66. package/lib/ProcessContainerForkBun.js +31 -0
  67. package/lib/ProcessUtils.js +74 -0
  68. package/lib/TreeKill.js +111 -0
  69. package/lib/Utility.js +304 -0
  70. package/lib/VersionCheck.js +46 -0
  71. package/lib/Watcher.js +117 -0
  72. package/lib/Worker.js +200 -0
  73. package/lib/binaries/CLI.js +1092 -0
  74. package/lib/binaries/DevCLI.js +183 -0
  75. package/lib/binaries/Runtime.js +101 -0
  76. package/lib/binaries/Runtime4Docker.js +192 -0
  77. package/lib/completion.js +229 -0
  78. package/lib/completion.sh +40 -0
  79. package/lib/motd +36 -0
  80. package/lib/templates/Dockerfiles/Dockerfile-nodejs.tpl +8 -0
  81. package/lib/templates/ecosystem-es.tpl +24 -0
  82. package/lib/templates/ecosystem-simple-es.tpl +8 -0
  83. package/lib/templates/ecosystem-simple.tpl +6 -0
  84. package/lib/templates/ecosystem.tpl +22 -0
  85. package/lib/templates/init-scripts/launchd.tpl +35 -0
  86. package/lib/templates/init-scripts/openrc.tpl +52 -0
  87. package/lib/templates/init-scripts/pm2-init-amazon.sh +86 -0
  88. package/lib/templates/init-scripts/rcd-openbsd.tpl +41 -0
  89. package/lib/templates/init-scripts/rcd.tpl +44 -0
  90. package/lib/templates/init-scripts/smf.tpl +43 -0
  91. package/lib/templates/init-scripts/systemd-online.tpl +22 -0
  92. package/lib/templates/init-scripts/systemd.tpl +22 -0
  93. package/lib/templates/init-scripts/upstart.tpl +103 -0
  94. package/lib/templates/logrotate.d/pm2 +10 -0
  95. package/lib/templates/sample-apps/http-server/README.md +14 -0
  96. package/lib/templates/sample-apps/http-server/api.js +9 -0
  97. package/lib/templates/sample-apps/http-server/ecosystem.config.js +14 -0
  98. package/lib/templates/sample-apps/http-server/package.json +11 -0
  99. package/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md +45 -0
  100. package/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js +66 -0
  101. package/lib/templates/sample-apps/pm2-plus-metrics-actions/ecosystem.config.js +12 -0
  102. package/lib/templates/sample-apps/pm2-plus-metrics-actions/package.json +11 -0
  103. package/lib/templates/sample-apps/python-app/README.md +4 -0
  104. package/lib/templates/sample-apps/python-app/echo.py +7 -0
  105. package/lib/templates/sample-apps/python-app/ecosystem.config.js +12 -0
  106. package/lib/templates/sample-apps/python-app/package.json +11 -0
  107. package/lib/tools/Config.js +251 -0
  108. package/lib/tools/SysMetrics.js +375 -0
  109. package/lib/tools/copydirSync.js +101 -0
  110. package/lib/tools/deleteFolderRecursive.js +19 -0
  111. package/lib/tools/find-package-json.js +74 -0
  112. package/lib/tools/fmt.js +72 -0
  113. package/lib/tools/interpreter.js +88 -0
  114. package/lib/tools/isbinaryfile.js +94 -0
  115. package/lib/tools/json5.js +752 -0
  116. package/lib/tools/multimeter/bar.js +111 -0
  117. package/lib/tools/multimeter/charm/encode.js +18 -0
  118. package/lib/tools/multimeter/charm/index.js +305 -0
  119. package/lib/tools/multimeter/index.js +76 -0
  120. package/lib/tools/open.js +56 -0
  121. package/lib/tools/passwd.js +58 -0
  122. package/lib/tools/pm2-config-keys.js +165 -0
  123. package/lib/tools/prompt.js +76 -0
  124. package/lib/tools/serviceStop.js +149 -0
  125. package/lib/tools/sexec.js +55 -0
  126. package/lib/tools/treeify.js +113 -0
  127. package/lib/tools/typestrip.js +55 -0
  128. package/lib/tools/which.js +120 -0
  129. package/lib/tools/xdg-open +861 -0
  130. package/modules/blessed/LICENSE +20 -0
  131. package/modules/blessed/README.md +34 -0
  132. package/modules/blessed/index.js +1 -0
  133. package/modules/blessed/lib/alias.js +526 -0
  134. package/modules/blessed/lib/blessed.js +32 -0
  135. package/modules/blessed/lib/colors.js +530 -0
  136. package/modules/blessed/lib/events.js +189 -0
  137. package/modules/blessed/lib/gpmclient.js +221 -0
  138. package/modules/blessed/lib/helpers.js +165 -0
  139. package/modules/blessed/lib/keys.js +339 -0
  140. package/modules/blessed/lib/program.js +4297 -0
  141. package/modules/blessed/lib/tput.js +3022 -0
  142. package/modules/blessed/lib/unicode.js +885 -0
  143. package/modules/blessed/lib/widget.js +32 -0
  144. package/modules/blessed/lib/widgets/box.js +34 -0
  145. package/modules/blessed/lib/widgets/element.js +2570 -0
  146. package/modules/blessed/lib/widgets/list.js +599 -0
  147. package/modules/blessed/lib/widgets/log.js +83 -0
  148. package/modules/blessed/lib/widgets/node.js +282 -0
  149. package/modules/blessed/lib/widgets/screen.js +2298 -0
  150. package/modules/blessed/lib/widgets/scrollablebox.js +389 -0
  151. package/modules/blessed/lib/widgets/scrollabletext.js +35 -0
  152. package/modules/blessed/lib/widgets/text.js +35 -0
  153. package/modules/blessed/usr/linux +0 -0
  154. package/modules/blessed/usr/windows-ansi +0 -0
  155. package/modules/blessed/usr/xterm +0 -0
  156. package/modules/blessed/usr/xterm-256color +0 -0
  157. package/modules/blessed/usr/xterm.termcap +243 -0
  158. package/modules/chokidar/LICENSE +21 -0
  159. package/modules/chokidar/VENDORED.md +76 -0
  160. package/modules/chokidar/index.js +979 -0
  161. package/modules/chokidar/lib/brace-expand.js +180 -0
  162. package/modules/chokidar/lib/constants.js +66 -0
  163. package/modules/chokidar/lib/fsevents-handler.js +526 -0
  164. package/modules/chokidar/lib/nodefs-handler.js +654 -0
  165. package/modules/fclone.js +49 -0
  166. package/modules/pm2-axon/index.js +2 -0
  167. package/modules/pm2-axon/lib/configurable/History.md +5 -0
  168. package/modules/pm2-axon/lib/configurable/Makefile +7 -0
  169. package/modules/pm2-axon/lib/configurable/Readme.md +57 -0
  170. package/modules/pm2-axon/lib/configurable/index.js +2 -0
  171. package/modules/pm2-axon/lib/configurable/lib/configurable.js +47 -0
  172. package/modules/pm2-axon/lib/configurable/package.json +68 -0
  173. package/modules/pm2-axon/lib/index.js +44 -0
  174. package/modules/pm2-axon/lib/plugins/queue.js +71 -0
  175. package/modules/pm2-axon/lib/plugins/round-robin.js +55 -0
  176. package/modules/pm2-axon/lib/sockets/pub-emitter.js +26 -0
  177. package/modules/pm2-axon/lib/sockets/pub.js +77 -0
  178. package/modules/pm2-axon/lib/sockets/pull.js +37 -0
  179. package/modules/pm2-axon/lib/sockets/push.js +32 -0
  180. package/modules/pm2-axon/lib/sockets/rep.js +73 -0
  181. package/modules/pm2-axon/lib/sockets/req.js +101 -0
  182. package/modules/pm2-axon/lib/sockets/sock.js +430 -0
  183. package/modules/pm2-axon/lib/sockets/sub-emitter.js +92 -0
  184. package/modules/pm2-axon/lib/sockets/sub.js +147 -0
  185. package/modules/pm2-axon/lib/utils.js +19 -0
  186. package/modules/pm2-axon-rpc/index.js +3 -0
  187. package/modules/pm2-axon-rpc/lib/client.js +63 -0
  188. package/modules/pm2-axon-rpc/lib/server.js +139 -0
  189. package/modules/pm2-io-agent/LICENSE +661 -0
  190. package/modules/pm2-io-agent/README.md +62 -0
  191. package/modules/pm2-io-agent/config.js +30 -0
  192. package/modules/pm2-io-agent/constants.js +118 -0
  193. package/modules/pm2-io-agent/index.js +2 -0
  194. package/modules/pm2-io-agent/src/InteractorClient.js +513 -0
  195. package/modules/pm2-io-agent/src/InteractorDaemon.js +455 -0
  196. package/modules/pm2-io-agent/src/PM2Client.js +112 -0
  197. package/modules/pm2-io-agent/src/PM2Interface.js +180 -0
  198. package/modules/pm2-io-agent/src/TransporterInterface.js +173 -0
  199. package/modules/pm2-io-agent/src/Utility.js +392 -0
  200. package/modules/pm2-io-agent/src/WatchDog.js +70 -0
  201. package/modules/pm2-io-agent/src/push/DataRetriever.js +77 -0
  202. package/modules/pm2-io-agent/src/push/PushInteractor.js +206 -0
  203. package/modules/pm2-io-agent/src/push/TransactionAggregator.js +670 -0
  204. package/modules/pm2-io-agent/src/reverse/ReverseInteractor.js +128 -0
  205. package/modules/pm2-io-agent/src/transporters/Transporter.js +129 -0
  206. package/modules/pm2-io-agent/src/transporters/WebsocketTransport.js +202 -0
  207. package/modules/pm2-io-agent/src/utils/BinaryHeap.js +135 -0
  208. package/modules/pm2-io-agent/src/utils/EDS.js +111 -0
  209. package/modules/pm2-io-agent/src/utils/probes/Histogram.js +204 -0
  210. package/modules/pm2-io-agent/src/utils/units.js +10 -0
  211. package/modules/pm2-io-bpm/configuration.js +141 -0
  212. package/modules/pm2-io-bpm/constants.js +10 -0
  213. package/modules/pm2-io-bpm/featureManager.js +110 -0
  214. package/modules/pm2-io-bpm/features/dependencies.js +48 -0
  215. package/modules/pm2-io-bpm/features/events.js +50 -0
  216. package/modules/pm2-io-bpm/features/metrics.js +102 -0
  217. package/modules/pm2-io-bpm/features/notify.js +238 -0
  218. package/modules/pm2-io-bpm/features/profiling.js +70 -0
  219. package/modules/pm2-io-bpm/features/tracing.js +174 -0
  220. package/modules/pm2-io-bpm/index.js +11 -0
  221. package/modules/pm2-io-bpm/metrics/eventLoopMetrics.js +136 -0
  222. package/modules/pm2-io-bpm/metrics/httpMetrics.js +175 -0
  223. package/modules/pm2-io-bpm/metrics/network.js +132 -0
  224. package/modules/pm2-io-bpm/metrics/runtime.js +161 -0
  225. package/modules/pm2-io-bpm/metrics/v8.js +104 -0
  226. package/modules/pm2-io-bpm/otel/constants.js +7 -0
  227. package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/platform/index.js +17 -0
  228. package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/platform/node/index.js +17 -0
  229. package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/platform/node/util.js +51 -0
  230. package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/transform.js +137 -0
  231. package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/types.js +24 -0
  232. package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/utils.js +23 -0
  233. package/modules/pm2-io-bpm/otel/custom-zipkin-exporter/zipkin.js +149 -0
  234. package/modules/pm2-io-bpm/pmx.js +380 -0
  235. package/modules/pm2-io-bpm/profilers/addonProfiler.js +193 -0
  236. package/modules/pm2-io-bpm/profilers/inspectorProfiler.js +302 -0
  237. package/modules/pm2-io-bpm/serviceManager.js +21 -0
  238. package/modules/pm2-io-bpm/services/actions.js +159 -0
  239. package/modules/pm2-io-bpm/services/inspector.js +43 -0
  240. package/modules/pm2-io-bpm/services/metrics.js +186 -0
  241. package/modules/pm2-io-bpm/services/runtimeStats.js +54 -0
  242. package/modules/pm2-io-bpm/services/transport.js +11 -0
  243. package/modules/pm2-io-bpm/transports/IPCTransport.js +115 -0
  244. package/modules/pm2-io-bpm/utils/BinaryHeap.js +134 -0
  245. package/modules/pm2-io-bpm/utils/EDS.js +113 -0
  246. package/modules/pm2-io-bpm/utils/EWMA.js +32 -0
  247. package/modules/pm2-io-bpm/utils/autocast.js +61 -0
  248. package/modules/pm2-io-bpm/utils/metrics/counter.js +33 -0
  249. package/modules/pm2-io-bpm/utils/metrics/gauge.js +23 -0
  250. package/modules/pm2-io-bpm/utils/metrics/histogram.js +192 -0
  251. package/modules/pm2-io-bpm/utils/metrics/meter.js +46 -0
  252. package/modules/pm2-io-bpm/utils/miscellaneous.js +19 -0
  253. package/modules/pm2-io-bpm/utils/module.js +67 -0
  254. package/modules/pm2-io-bpm/utils/shimmer.js +19 -0
  255. package/modules/pm2-io-bpm/utils/stackParser.js +160 -0
  256. package/modules/pm2-io-bpm/utils/transactionAggregator.js +429 -0
  257. package/modules/pm2-io-bpm/utils/units.js +16 -0
  258. package/modules/vizion/LICENSE +13 -0
  259. package/modules/vizion/README.md +133 -0
  260. package/modules/vizion/index.js +1 -0
  261. package/modules/vizion/lib/git/git.js +247 -0
  262. package/modules/vizion/lib/vizion.js +52 -0
  263. package/package.json +170 -4
  264. package/paths.js +121 -0
  265. package/pm2 +11 -0
  266. package/types/index.d.ts +732 -0
  267. package/types/tsconfig.json +14 -0
package/README.md CHANGED
@@ -1,3 +1,256 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
+ <br/>
2
3
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
+ <picture>
5
+ <source
6
+ srcset="https://raw.githubusercontent.com/Unitech/pm2/master/pres/pm2-v4.png"
7
+ width=710px
8
+ media="(prefers-color-scheme: light)"
9
+ />
10
+ <source
11
+ srcset="https://raw.githubusercontent.com/Unitech/pm2/master/pres/pm2-v4-dark-mode.png"
12
+ width=710px
13
+ media="(prefers-color-scheme: dark), (prefers-color-scheme: no-preference)"
14
+ />
15
+ <img src="https://raw.githubusercontent.com/Unitech/pm2/master/pres/pm2-v4.png" alt="PM2" />
16
+ </picture>
17
+
18
+ <br/>
19
+ <br/>
20
+ <b>P</b>(rocess) <b>M</b>(anager) <b>2</b><br/>
21
+ <i>Runtime Edition</i>
22
+ <br/><br/>
23
+
24
+
25
+ <a title="PM2 Downloads" href="https://npm-stat.com/charts.html?package=pm2">
26
+ <img src="https://img.shields.io/npm/dm/pm2" alt="Downloads per Month"/>
27
+ </a>
28
+
29
+ <a title="PM2 Downloads" href="https://npm-stat.com/charts.html?package=pm2">
30
+ <img src="https://img.shields.io/npm/dy/pm2" alt="Downloads per Year"/>
31
+ </a>
32
+
33
+ <a href="https://badge.fury.io/js/pm2" title="NPM Version Badge">
34
+ <img src="https://badge.fury.io/js/pm2.svg" alt="npm version">
35
+ </a>
36
+
37
+ <br/>
38
+ <br/>
39
+ <br/>
40
+ </div>
41
+
42
+
43
+ PM2 is a production process manager for Node.js/Bun applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.
44
+
45
+ Starting an application in production mode is as easy as:
46
+
47
+ ```bash
48
+ $ pm2 start app.js
49
+ ```
50
+
51
+ PM2 is battle-tested by [a comprehensive test suite](https://github.com/Unitech/pm2/actions/workflows/node.js.yml).
52
+
53
+ Official website: [https://pm2.keymetrics.io/](https://pm2.keymetrics.io/)
54
+
55
+ Works on Linux, macOS, and Windows. Supports Node.js 18+ and Bun 1+.
56
+
57
+
58
+ ## Installing PM2
59
+
60
+ ### With NPM
61
+
62
+ ```bash
63
+ $ npm install pm2 -g
64
+ ```
65
+
66
+ ### With Bun
67
+
68
+ ```bash
69
+ $ bun install pm2 -g
70
+ ```
71
+
72
+ If you only have Bun installed (no Node.js), symlink `node` to `bun` so PM2's `#!/usr/bin/env node` shebang resolves to Bun's node-compatibility runtime:
73
+
74
+ ```bash
75
+ $ sudo ln -s $(which bun) /usr/local/bin/node
76
+ ```
77
+
78
+ ___
79
+
80
+ You can install Node.js easily with [NVM](https://github.com/nvm-sh/nvm#installing-and-updating) or [FNM](https://github.com/Schniz/fnm) or install Bun with `curl -fsSL https://bun.sh/install | bash`
81
+
82
+ ### Start an application
83
+
84
+ You can start any application (Node.js, Bun, and also Python, Ruby, binaries in $PATH...) like that:
85
+
86
+ ```bash
87
+ $ pm2 start app.js
88
+ $ pm2 start app.ts
89
+ $ pm2 start app.py
90
+ ```
91
+
92
+ Your app is now daemonized, monitored and kept alive forever.
93
+
94
+ ### Managing Applications
95
+
96
+ Once applications are started you can manage them easily:
97
+
98
+ ![Process listing](https://github.com/Unitech/pm2/raw/master/pres/pm2-ls-v2.png)
99
+
100
+ To list all running applications:
101
+
102
+ ```bash
103
+ $ pm2 list
104
+ ```
105
+
106
+ Managing apps is straightforward:
107
+
108
+ ```bash
109
+ $ pm2 stop <app_name|namespace|id|'all'|json_conf>
110
+ $ pm2 restart <app_name|namespace|id|'all'|json_conf>
111
+ $ pm2 delete <app_name|namespace|id|'all'|json_conf>
112
+ ```
113
+
114
+ To have more details on a specific application:
115
+
116
+ ```bash
117
+ $ pm2 describe <id|app_name>
118
+ ```
119
+
120
+ To monitor logs, custom metrics, application information:
121
+
122
+ ```bash
123
+ $ pm2 monit
124
+ ```
125
+
126
+ [More about Process Management](https://pm2.keymetrics.io/docs/usage/process-management/)
127
+
128
+ ### Cluster Mode: Node.js Load Balancing & Zero Downtime Reload
129
+
130
+ Cluster mode starts multiple Node.js processes and load-balances HTTP/TCP/UDP queries between them. This significantly increases throughput on multi-core machines and improves reliability (faster socket re-balancing in case of unhandled errors).
131
+
132
+ ![Framework supported](https://raw.githubusercontent.com/Unitech/pm2/master/pres/cluster.png)
133
+
134
+ Starting a Node.js application in cluster mode that will leverage all CPUs available:
135
+
136
+ ```bash
137
+ $ pm2 start api.js -i <processes>
138
+ ```
139
+
140
+ `<processes>` can be `'max'`, `-1` (all cpu minus 1) or a specified number of instances to start.
141
+
142
+ **Zero Downtime Reload**
143
+
144
+ Hot Reload allows you to update an application without any downtime:
145
+
146
+ ```bash
147
+ $ pm2 reload all
148
+ ```
149
+
150
+ [More information about how PM2 makes clustering easy](https://pm2.keymetrics.io/docs/usage/cluster-mode/)
151
+
152
+ ### Container Support
153
+
154
+ With the drop-in replacement command for `node`, called `pm2-runtime`, run your Node.js application in a hardened production environment.
155
+ Using it is seamless:
156
+
157
+ ```dockerfile
158
+ RUN npm install pm2 -g
159
+ CMD [ "pm2-runtime", "npm", "--", "start" ]
160
+ ```
161
+
162
+ [Read More about the dedicated integration](https://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/)
163
+
164
+ ### Terminal Based Monitoring
165
+
166
+ ![Monit](https://github.com/Unitech/pm2/raw/master/pres/pm2-monit.png)
167
+
168
+ Monitor all processes launched straight from the command line:
169
+
170
+ ```bash
171
+ $ pm2 monit
172
+ ```
173
+
174
+ ### Log Management
175
+
176
+ To consult logs just type the command:
177
+
178
+ ```bash
179
+ $ pm2 logs
180
+ ```
181
+
182
+ Standard, Raw, JSON and formatted output are available.
183
+
184
+ Examples:
185
+
186
+ ```bash
187
+ $ pm2 logs APP-NAME # Display APP-NAME logs
188
+ $ pm2 logs --json # JSON output
189
+ $ pm2 logs --format # Formatted output
190
+
191
+ $ pm2 flush # Flush all logs
192
+ $ pm2 reloadLogs # Reload all logs
193
+ ```
194
+
195
+ To enable log rotation install the following module
196
+
197
+ ```bash
198
+ $ pm2 install pm2-logrotate
199
+ ```
200
+
201
+ [More about log management](https://pm2.keymetrics.io/docs/usage/log-management/)
202
+
203
+ ### Startup Scripts Generation
204
+
205
+ PM2 can generate and configure a Startup Script to keep PM2 and your processes alive at every server restart.
206
+
207
+ Init Systems Supported: **systemd**, **upstart**, **systemv**, **openrc**, **launchd**, **rcd**, **rcd-openbsd**, **smf**
208
+
209
+ ```bash
210
+ # Generate Startup Script
211
+ $ pm2 startup
212
+
213
+ # Freeze your process list across server restart
214
+ $ pm2 save
215
+
216
+ # Remove Startup Script
217
+ $ pm2 unstartup
218
+ ```
219
+
220
+ [More about Startup Scripts Generation](https://pm2.keymetrics.io/docs/usage/startup/)
221
+
222
+ ### Updating PM2
223
+
224
+ ```bash
225
+ # Install latest PM2 version
226
+ $ npm install pm2@latest -g
227
+ # Save process list, exit old PM2 & restore all processes
228
+ $ pm2 update
229
+ ```
230
+
231
+ *PM2 updates are seamless*
232
+
233
+ ## PM2+ Monitoring
234
+
235
+ If you manage your apps with PM2, PM2+ makes it easy to monitor and manage apps across servers.
236
+
237
+ ![https://app.pm2.io/](https://pm2.io/img/app-overview.png)
238
+
239
+ Feel free to try it:
240
+
241
+ [Discover the monitoring dashboard for PM2](https://app.pm2.io/)
242
+
243
+ Thanks in advance and we hope that you like PM2!
244
+
245
+ ## CHANGELOG
246
+
247
+ [CHANGELOG](https://github.com/Unitech/pm2/blob/master/CHANGELOG.md)
248
+
249
+ ## Contributors
250
+
251
+ [Contributors](https://pm2.keymetrics.io/hall-of-fame/)
252
+
253
+ ## License
254
+
255
+ PM2 is made available under the terms of the GNU Affero General Public License 3.0 (AGPL 3.0).
256
+ For other licenses [contact us](mailto:contact@keymetrics.io).
package/SECURITY.md ADDED
@@ -0,0 +1,41 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ Please **do not open a public issue** for security bugs.
6
+
7
+ Report vulnerabilities privately via [GitHub Security Advisories](https://github.com/Unitech/pm2/security/advisories/new).
8
+ If you cannot use GitHub, email `alexandre [at] keymetrics [dot] io` with a description of the issue and steps to reproduce.
9
+
10
+ What to expect:
11
+
12
+ - Acknowledgment within **72 hours**.
13
+ - We follow coordinated disclosure: we will work with you on a fix and publish a security advisory (with a CVE when applicable) once a patched release is available. We ask for a standard 90-day embargo.
14
+ - Reporters are credited in the advisory unless they prefer to remain anonymous.
15
+ - There is currently no bug bounty program.
16
+
17
+ ## Supported Versions
18
+
19
+ | Version | Supported |
20
+ | ------- | ------------------ |
21
+ | 7.x | :white_check_mark: |
22
+ | < 7.0 | :x: |
23
+
24
+ ## Scope
25
+
26
+ PM2 is a process manager: it is designed to execute arbitrary commands on behalf of the user running it. Its trust boundary is the user account that owns the PM2 daemon — the RPC socket (`~/.pm2/rpc.sock`) is intentionally accessible to that user only.
27
+
28
+ **In scope:**
29
+
30
+ - Privilege escalation across user accounts or from a managed process to the daemon owner
31
+ - Remote code execution in the daemon, RPC layer, or agent that crosses a trust boundary
32
+ - Vulnerabilities in log, configuration, or ecosystem file parsing
33
+ - Path traversal or arbitrary write in module installation (`pm2 install`)
34
+ - Exposure of secrets in logs, dumps, or monitoring data
35
+
36
+ **Out of scope (by design):**
37
+
38
+ - "PM2 can execute arbitrary commands" — that is its purpose
39
+ - Attacks requiring access to the same user account that owns the daemon
40
+ - Vulnerable dependencies without a demonstrated exploit path through PM2
41
+ - Denial of service through intentional misconfiguration
package/bin/pm2 ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../lib/binaries/CLI.js');
package/bin/pm2-dev ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../lib/binaries/DevCLI.js');
package/bin/pm2-docker ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../lib/binaries/Runtime4Docker.js');
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../lib/binaries/Runtime4Docker.js');
package/bin/pm2.ps1 ADDED
@@ -0,0 +1,3 @@
1
+ # pm2.ps1
2
+ $pm2Path = Join-Path $PSScriptRoot "../lib/binaries/CLI.js"
3
+ node $pm2Path $args
package/constants.js ADDED
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Copyright 2013-present the PM2 project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ var debug = require('debug')('pm2:conf');
8
+ var p = require('path');
9
+ var util = require('util');
10
+ var chalk = require('ansis');
11
+
12
+ /**
13
+ * Get PM2 path structure
14
+ */
15
+ var path_structure = require('./paths.js')(process.env.OVER_HOME);
16
+
17
+ /**
18
+ * Constants variables used by PM2
19
+ */
20
+ var csts = {
21
+ PREFIX_MSG : chalk.green('[PM2] '),
22
+ PREFIX_MSG_INFO : chalk.cyan('[PM2][INFO] '),
23
+ PREFIX_MSG_ERR : chalk.red('[PM2][ERROR] '),
24
+ PREFIX_MSG_MOD : chalk.bold.green('[PM2][Module] '),
25
+ PREFIX_MSG_MOD_ERR : chalk.red('[PM2][Module][ERROR] '),
26
+ PREFIX_MSG_WARNING : chalk.yellow('[PM2][WARN] '),
27
+ PREFIX_MSG_SUCCESS : chalk.cyan('[PM2] '),
28
+
29
+ PM2_IO_MSG : chalk.cyan('[PM2 I/O]'),
30
+ PM2_IO_MSG_ERR : chalk.red('[PM2 I/O]'),
31
+
32
+ TEMPLATE_FOLDER : p.join(__dirname, 'lib/templates'),
33
+
34
+ APP_CONF_DEFAULT_FILE : 'ecosystem.config.js',
35
+ APP_CONF_TPL : 'ecosystem.tpl',
36
+ APP_CONF_TPL_SIMPLE : 'ecosystem-simple.tpl',
37
+ SAMPLE_CONF_FILE : 'sample-conf.js',
38
+ LOGROTATE_SCRIPT : 'logrotate.d/pm2',
39
+
40
+ DOCKERFILE_NODEJS : 'Dockerfiles/Dockerfile-nodejs.tpl',
41
+
42
+ SUCCESS_EXIT : 0,
43
+ ERROR_EXIT : 1,
44
+ CODE_UNCAUGHTEXCEPTION : 1,
45
+
46
+ IS_BUN : typeof Bun !== 'undefined',
47
+ IS_WINDOWS : (process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE)),
48
+ ONLINE_STATUS : 'online',
49
+ STOPPED_STATUS : 'stopped',
50
+ STOPPING_STATUS : 'stopping',
51
+ WAITING_RESTART : 'waiting restart',
52
+ LAUNCHING_STATUS : 'launching',
53
+ ERRORED_STATUS : 'errored',
54
+ ONE_LAUNCH_STATUS : 'one-launch-status',
55
+
56
+ CLUSTER_MODE_ID : 'cluster_mode',
57
+ FORK_MODE_ID : 'fork_mode',
58
+
59
+ ENABLE_GIT_PARSING : process.env.PM2_ENABLE_GIT_PARSING === 'true' || false,
60
+ LOW_MEMORY_ENVIRONMENT : process.env.PM2_OPTIMIZE_MEMORY || false,
61
+
62
+ MACHINE_NAME : process.env.INSTANCE_NAME || process.env.MACHINE_NAME || process.env.PM2_MACHINE_NAME,
63
+ SECRET_KEY : process.env.KEYMETRICS_SECRET || process.env.PM2_SECRET_KEY || process.env.SECRET_KEY,
64
+ PUBLIC_KEY : process.env.KEYMETRICS_PUBLIC || process.env.PM2_PUBLIC_KEY || process.env.PUBLIC_KEY,
65
+ KEYMETRICS_ROOT_URL : process.env.KEYMETRICS_NODE || process.env.PM2_APM_ADDRESS || process.env.ROOT_URL || process.env.INFO_NODE || 'root.keymetrics.io',
66
+
67
+
68
+ PM2_BANNER : '../lib/motd',
69
+ PM2_UPDATE : '../lib/API/pm2-plus/pres/motd.update',
70
+ DEFAULT_MODULE_JSON : 'package.json',
71
+
72
+ MODULE_BASEFOLDER: 'module',
73
+ MODULE_CONF_PREFIX: 'module-db-v2',
74
+ MODULE_CONF_PREFIX_TAR: 'tar-modules',
75
+
76
+ EXP_BACKOFF_RESET_TIMER : parseInt(process.env.EXP_BACKOFF_RESET_TIMER) || 30000,
77
+ REMOTE_PORT_TCP : isNaN(parseInt(process.env.KEYMETRICS_PUSH_PORT)) ? 80 : parseInt(process.env.KEYMETRICS_PUSH_PORT),
78
+ REMOTE_PORT : 41624,
79
+ REMOTE_HOST : 's1.keymetrics.io',
80
+ SEND_INTERVAL : 1000,
81
+ RELOAD_LOCK_TIMEOUT : parseInt(process.env.PM2_RELOAD_LOCK_TIMEOUT) || 30000,
82
+ GRACEFUL_TIMEOUT : parseInt(process.env.PM2_GRACEFUL_TIMEOUT) || 8000,
83
+ GRACEFUL_LISTEN_TIMEOUT : parseInt(process.env.PM2_GRACEFUL_LISTEN_TIMEOUT) || 3000,
84
+ LOGS_BUFFER_SIZE : 8,
85
+ CONTEXT_ON_ERROR : 2,
86
+ AGGREGATION_DURATION : process.env.PM2_DEBUG || process.env.NODE_ENV === 'local_test' || process.env.NODE_ENV === 'development' ? 3000 : 5 * 60000,
87
+ TRACE_FLUSH_INTERVAL : process.env.PM2_DEBUG || process.env.NODE_ENV === 'local_test' ? 1000 : 60000,
88
+
89
+ // Concurrent actions when doing start/restart/reload
90
+ CONCURRENT_ACTIONS : (function() {
91
+ var concurrent_actions = parseInt(process.env.PM2_CONCURRENT_ACTIONS) || 2;
92
+ debug('Using %d parallelism (CONCURRENT_ACTIONS)', concurrent_actions);
93
+ return concurrent_actions;
94
+ })(),
95
+
96
+ DEBUG : process.env.PM2_DEBUG || false,
97
+ WEB_IPADDR : process.env.PM2_API_IPADDR || '0.0.0.0',
98
+ WEB_PORT : parseInt(process.env.PM2_API_PORT) || 9615,
99
+ WEB_STRIP_ENV_VARS : process.env.PM2_WEB_STRIP_ENV_VARS || false,
100
+ MODIFY_REQUIRE : process.env.PM2_MODIFY_REQUIRE || false,
101
+
102
+ WORKER_INTERVAL : process.env.PM2_WORKER_INTERVAL || 30000,
103
+ KILL_TIMEOUT : process.env.PM2_KILL_TIMEOUT || 1600,
104
+ KILL_RETRY_TIME : process.env.PM2_KILL_RETRY_TIME || 100,
105
+ KILL_SIGNAL : process.env.PM2_KILL_SIGNAL || 'SIGINT',
106
+ KILL_USE_MESSAGE : process.env.PM2_KILL_USE_MESSAGE || false,
107
+
108
+ PM2_PROGRAMMATIC : typeof(process.env.pm_id) !== 'undefined' || process.env.PM2_PROGRAMMATIC,
109
+ PM2_LOG_DATE_FORMAT : process.env.PM2_LOG_DATE_FORMAT !== undefined ? process.env.PM2_LOG_DATE_FORMAT : 'YYYY-MM-DDTHH:mm:ss'
110
+
111
+ };
112
+
113
+ module.exports = Object.assign(csts, path_structure);
package/index.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright 2013-present the PM2 project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ process.env.PM2_PROGRAMMATIC = 'true';
8
+
9
+ var API = require('./lib/API.js');
10
+
11
+ module.exports = new API;
12
+ module.exports.custom = API;
@@ -0,0 +1,212 @@
1
+
2
+ var Common = require('../Common.js');
3
+ var cst = require('../../constants.js');
4
+ var UX = require('./UX');
5
+ var chalk = require('ansis');
6
+ var Configuration = require('../Configuration.js');
7
+
8
+ module.exports = function(CLI) {
9
+
10
+ CLI.prototype.get = function(key, cb) {
11
+ var that = this;
12
+
13
+ if (!key || key == 'all') {
14
+ displayConf(function(err, data) {
15
+ if (err)
16
+ return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT);
17
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT);
18
+ });
19
+ return false;
20
+ }
21
+ Configuration.get(key, function(err, data) {
22
+ if (err) {
23
+ return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT);
24
+ }
25
+ // pm2 conf module-name
26
+ if (key.indexOf(':') === -1 && key.indexOf('.') === -1) {
27
+ displayConf(key, function() {
28
+ console.log('Modules configuration. Copy/Paste line to edit values.')
29
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)
30
+ });
31
+ return false;
32
+ }
33
+ // pm2 conf module-name:key
34
+ var module_name, key_name;
35
+
36
+ if (key.indexOf(':') > -1) {
37
+ module_name = key.split(':')[0];
38
+ key_name = key.split(':')[1];
39
+ } else if (key.indexOf('.') > -1) {
40
+ module_name = key.split('.')[0];
41
+ key_name = key.split('.')[1];
42
+ }
43
+
44
+ Common.printOut('Value for module ' + chalk.blue(module_name), 'key ' + chalk.blue(key_name) + ': ' + chalk.bold.green(data));
45
+
46
+
47
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT);
48
+ });
49
+ };
50
+
51
+ CLI.prototype.set = function(key, value, cb) {
52
+ var that = this;
53
+
54
+ if (!key) {
55
+ interactiveConfigEdit(function(err) {
56
+ if (err)
57
+ return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT);
58
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT);
59
+ });
60
+ return false;
61
+ }
62
+
63
+ /**
64
+ * Set value
65
+ */
66
+ Configuration.set(key, value, function(err) {
67
+ if (err)
68
+ return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT);
69
+
70
+ var values = [];
71
+
72
+ if (key.indexOf('.') > -1)
73
+ values = key.split('.');
74
+
75
+ if (key.indexOf(':') > -1)
76
+ values = key.split(':');
77
+
78
+ if (values && values.length > 1) {
79
+ // The first element is the app name (module_conf.json)
80
+ var app_name = values[0];
81
+
82
+ process.env.PM2_PROGRAMMATIC = 'true';
83
+ that.restart(app_name, {
84
+ updateEnv : true
85
+ }, function(err, data) {
86
+ process.env.PM2_PROGRAMMATIC = 'false';
87
+ if (!err)
88
+ Common.printOut(cst.PREFIX_MSG + 'Module %s restarted', app_name);
89
+ Common.log('Setting changed')
90
+ displayConf(app_name, function() {
91
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT);
92
+ });
93
+ });
94
+ return false;
95
+ }
96
+ displayConf(null, function() {
97
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT);
98
+ });
99
+ });
100
+ };
101
+
102
+ CLI.prototype.multiset = function(serial, cb) {
103
+ var that = this;
104
+
105
+ Configuration.multiset(serial, function(err, data) {
106
+ if (err)
107
+ return cb ? cb({success:false, err:err}) : that.exitCli(cst.ERROR_EXIT);
108
+
109
+ var values = [];
110
+ var key = serial.match(/(?:[^ "]+|"[^"]*")+/g)[0];
111
+
112
+ if (key.indexOf('.') > -1)
113
+ values = key.split('.');
114
+
115
+ if (key.indexOf(':') > -1)
116
+ values = key.split(':');
117
+
118
+ if (values && values.length > 1) {
119
+ // The first element is the app name (module_conf.json)
120
+ var app_name = values[0];
121
+
122
+ process.env.PM2_PROGRAMMATIC = 'true';
123
+ that.restart(app_name, {
124
+ updateEnv : true
125
+ }, function(err, data) {
126
+ process.env.PM2_PROGRAMMATIC = 'false';
127
+ if (!err)
128
+ Common.printOut(cst.PREFIX_MSG + 'Module %s restarted', app_name);
129
+ displayConf(app_name, function() {
130
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)
131
+ });
132
+ });
133
+ return false;
134
+ }
135
+ displayConf(app_name, function() {
136
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)
137
+ });
138
+ });
139
+ };
140
+
141
+ CLI.prototype.unset = function(key, cb) {
142
+ var that = this;
143
+
144
+ Configuration.unset(key, function(err) {
145
+ if (err) {
146
+ return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT);
147
+ }
148
+
149
+ displayConf(function() { cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT) });
150
+ });
151
+ };
152
+
153
+ CLI.prototype.conf = function(key, value, cb) {
154
+ var that = this;
155
+
156
+ if (typeof(value) === 'function') {
157
+ cb = value;
158
+ value = null;
159
+ }
160
+
161
+ // If key + value = set
162
+ if (key && value) {
163
+ that.set(key, value, function(err) {
164
+ if (err)
165
+ return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT);
166
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT);
167
+ });
168
+ }
169
+ // If only key = get
170
+ else if (key) {
171
+ that.get(key, function(err, data) {
172
+ if (err)
173
+ return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT);
174
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT);
175
+ });
176
+ }
177
+ else {
178
+ interactiveConfigEdit(function(err) {
179
+ if (err)
180
+ return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT);
181
+ return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT);
182
+ });
183
+ }
184
+ };
185
+
186
+ };
187
+
188
+ function interactiveConfigEdit(cb) {
189
+ UX.helpers.openEditor(cst.PM2_MODULE_CONF_FILE, function(err, data) {
190
+ Common.printOut(chalk.bold('Module configuration (%s) edited.'), cst.PM2_MODULE_CONF_FILE);
191
+ Common.printOut(chalk.bold('To take changes into account, please restart module related.'), cst.PM2_MODULE_CONF_FILE);
192
+ if (err)
193
+ return cb(Common.retErr(err));
194
+ return cb(null, {success:true});
195
+ });
196
+
197
+ }
198
+
199
+ /**
200
+ * Configuration
201
+ */
202
+ function displayConf(target_app, cb) {
203
+ if (typeof(target_app) == 'function') {
204
+ cb = target_app;
205
+ target_app = null;
206
+ }
207
+
208
+ Configuration.getAll(function(err, data) {
209
+ UX.helpers.dispKeys(data, target_app);
210
+ return cb();
211
+ });
212
+ }