@zappinginc/zm2 6.0.14

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 (133) hide show
  1. package/.claude/settings.local.json +8 -0
  2. package/.gitattributes +4 -0
  3. package/.mocharc.js +14 -0
  4. package/CHANGELOG.md +2416 -0
  5. package/CLAUDE.md +84 -0
  6. package/CONTRIBUTING.md +124 -0
  7. package/GNU-AGPL-3.0.txt +665 -0
  8. package/LICENSE +1 -0
  9. package/README.md +248 -0
  10. package/bin/zm2 +3 -0
  11. package/bin/zm2-dev +3 -0
  12. package/bin/zm2-docker +3 -0
  13. package/bin/zm2-runtime +3 -0
  14. package/bin/zm2-windows +3 -0
  15. package/bin/zm2.ps1 +3 -0
  16. package/bun.lock +421 -0
  17. package/constants.js +114 -0
  18. package/index.js +13 -0
  19. package/lib/API/Configuration.js +212 -0
  20. package/lib/API/Containerizer.js +335 -0
  21. package/lib/API/Dashboard.js +459 -0
  22. package/lib/API/Deploy.js +117 -0
  23. package/lib/API/Extra.js +775 -0
  24. package/lib/API/ExtraMgmt/Docker.js +30 -0
  25. package/lib/API/Log.js +315 -0
  26. package/lib/API/LogManagement.js +371 -0
  27. package/lib/API/Modules/LOCAL.js +122 -0
  28. package/lib/API/Modules/Modularizer.js +148 -0
  29. package/lib/API/Modules/NPM.js +445 -0
  30. package/lib/API/Modules/TAR.js +362 -0
  31. package/lib/API/Modules/flagExt.js +46 -0
  32. package/lib/API/Modules/index.js +120 -0
  33. package/lib/API/Monit.js +247 -0
  34. package/lib/API/Serve.js +343 -0
  35. package/lib/API/Startup.js +629 -0
  36. package/lib/API/UX/helpers.js +213 -0
  37. package/lib/API/UX/index.js +9 -0
  38. package/lib/API/UX/pm2-describe.js +193 -0
  39. package/lib/API/UX/pm2-ls-minimal.js +31 -0
  40. package/lib/API/UX/pm2-ls.js +483 -0
  41. package/lib/API/Version.js +382 -0
  42. package/lib/API/interpreter.json +12 -0
  43. package/lib/API/pm2-plus/PM2IO.js +372 -0
  44. package/lib/API/pm2-plus/auth-strategies/CliAuth.js +288 -0
  45. package/lib/API/pm2-plus/auth-strategies/WebAuth.js +187 -0
  46. package/lib/API/pm2-plus/helpers.js +97 -0
  47. package/lib/API/pm2-plus/link.js +126 -0
  48. package/lib/API/pm2-plus/pres/motd +16 -0
  49. package/lib/API/pm2-plus/pres/motd.update +26 -0
  50. package/lib/API/pm2-plus/pres/welcome +28 -0
  51. package/lib/API/pm2-plus/process-selector.js +52 -0
  52. package/lib/API/schema.json +379 -0
  53. package/lib/API.js +1931 -0
  54. package/lib/Client.js +776 -0
  55. package/lib/Common.js +911 -0
  56. package/lib/Configuration.js +304 -0
  57. package/lib/Daemon.js +456 -0
  58. package/lib/Event.js +37 -0
  59. package/lib/God/ActionMethods.js +909 -0
  60. package/lib/God/ClusterMode.js +97 -0
  61. package/lib/God/ForkMode.js +297 -0
  62. package/lib/God/Methods.js +265 -0
  63. package/lib/God/Reload.js +240 -0
  64. package/lib/God.js +632 -0
  65. package/lib/HttpInterface.js +76 -0
  66. package/lib/ProcessContainer.js +305 -0
  67. package/lib/ProcessContainerBun.js +360 -0
  68. package/lib/ProcessContainerFork.js +42 -0
  69. package/lib/ProcessContainerForkBun.js +33 -0
  70. package/lib/ProcessUtils.js +55 -0
  71. package/lib/TreeKill.js +118 -0
  72. package/lib/Utility.js +430 -0
  73. package/lib/VersionCheck.js +46 -0
  74. package/lib/Watcher.js +117 -0
  75. package/lib/Worker.js +169 -0
  76. package/lib/binaries/CLI.js +1041 -0
  77. package/lib/binaries/DevCLI.js +183 -0
  78. package/lib/binaries/Runtime.js +101 -0
  79. package/lib/binaries/Runtime4Docker.js +192 -0
  80. package/lib/completion.js +229 -0
  81. package/lib/completion.sh +40 -0
  82. package/lib/motd +36 -0
  83. package/lib/templates/Dockerfiles/Dockerfile-java.tpl +7 -0
  84. package/lib/templates/Dockerfiles/Dockerfile-nodejs.tpl +8 -0
  85. package/lib/templates/Dockerfiles/Dockerfile-ruby.tpl +7 -0
  86. package/lib/templates/ecosystem-es.tpl +24 -0
  87. package/lib/templates/ecosystem-simple-es.tpl +8 -0
  88. package/lib/templates/ecosystem-simple.tpl +6 -0
  89. package/lib/templates/ecosystem.tpl +22 -0
  90. package/lib/templates/init-scripts/launchd.tpl +35 -0
  91. package/lib/templates/init-scripts/openrc.tpl +52 -0
  92. package/lib/templates/init-scripts/pm2-init-amazon.sh +86 -0
  93. package/lib/templates/init-scripts/rcd-openbsd.tpl +41 -0
  94. package/lib/templates/init-scripts/rcd.tpl +44 -0
  95. package/lib/templates/init-scripts/smf.tpl +43 -0
  96. package/lib/templates/init-scripts/systemd-online.tpl +22 -0
  97. package/lib/templates/init-scripts/systemd.tpl +22 -0
  98. package/lib/templates/init-scripts/upstart.tpl +103 -0
  99. package/lib/templates/logrotate.d/pm2 +10 -0
  100. package/lib/templates/sample-apps/http-server/README.md +14 -0
  101. package/lib/templates/sample-apps/http-server/api.js +9 -0
  102. package/lib/templates/sample-apps/http-server/ecosystem.config.js +14 -0
  103. package/lib/templates/sample-apps/http-server/package.json +11 -0
  104. package/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md +45 -0
  105. package/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js +66 -0
  106. package/lib/templates/sample-apps/pm2-plus-metrics-actions/ecosystem.config.js +12 -0
  107. package/lib/templates/sample-apps/pm2-plus-metrics-actions/package.json +11 -0
  108. package/lib/templates/sample-apps/python-app/README.md +4 -0
  109. package/lib/templates/sample-apps/python-app/echo.py +7 -0
  110. package/lib/templates/sample-apps/python-app/ecosystem.config.js +12 -0
  111. package/lib/templates/sample-apps/python-app/package.json +11 -0
  112. package/lib/tools/Config.js +248 -0
  113. package/lib/tools/IsAbsolute.js +20 -0
  114. package/lib/tools/copydirSync.js +101 -0
  115. package/lib/tools/deleteFolderRecursive.js +19 -0
  116. package/lib/tools/find-package-json.js +74 -0
  117. package/lib/tools/fmt.js +72 -0
  118. package/lib/tools/isbinaryfile.js +94 -0
  119. package/lib/tools/json5.js +752 -0
  120. package/lib/tools/open.js +63 -0
  121. package/lib/tools/passwd.js +58 -0
  122. package/lib/tools/promise.min.js +1 -0
  123. package/lib/tools/sexec.js +55 -0
  124. package/lib/tools/treeify.js +113 -0
  125. package/lib/tools/which.js +120 -0
  126. package/lib/tools/xdg-open +861 -0
  127. package/package.json +219 -0
  128. package/paths.js +93 -0
  129. package/pm2 +11 -0
  130. package/preinstall.js +24 -0
  131. package/run.sh +9 -0
  132. package/types/index.d.ts +722 -0
  133. package/types/tsconfig.json +14 -0
package/CLAUDE.md ADDED
@@ -0,0 +1,84 @@
1
+ # CLAUDE.md - PM2 Project Guide
2
+
3
+ ## Project Overview
4
+
5
+ PM2 is a production process manager for Node.js/Bun applications with a built-in load balancer. Version 6.0.14, licensed under AGPL-3.0. Minimum Node.js version: 16.
6
+
7
+ ## Quick Commands
8
+
9
+ ```bash
10
+ npm test # Run all tests (e2e + unit)
11
+ npm run test:unit # Unit tests only (bash test/unit.sh)
12
+ npm run test:e2e # E2E tests only (bash test/e2e.sh)
13
+ pm2 update # Restart daemon after modifying Daemon.js, God.js, God/*, Watcher.js
14
+ ```
15
+
16
+ ## Architecture
17
+
18
+ - **Entry points**: `index.js` (programmatic API), `bin/pm2` (CLI)
19
+ - **API** (`lib/API.js`): Main programmatic interface, ~1900 lines
20
+ - **Daemon** (`lib/Daemon.js`): Daemon lifecycle, uses pm2-axon for RPC/messaging
21
+ - **God** (`lib/God.js` + `lib/God/`): Core process monitoring — ClusterMode, ForkMode, Reload, ActionMethods
22
+ - **Client** (`lib/Client.js`): RPC client for daemon communication
23
+ - **CLI** (`lib/binaries/CLI.js`): Commander.js-based CLI with 90+ options
24
+ - **Process containers**: `ProcessContainer.js` (Node), `ProcessContainerBun.js` (Bun)
25
+ - **API modules** (`lib/API/`): Dashboard, Deploy, Log, Startup, Modules, pm2-plus, etc.
26
+ - **Tools** (`lib/tools/`): Utility functions (Config, json5, sexec, which, etc.)
27
+
28
+ ## Key Directories
29
+
30
+ ```
31
+ bin/ CLI entry points (pm2, pm2-dev, pm2-docker, pm2-runtime)
32
+ lib/ Core source code
33
+ lib/API/ Extended API modules (Deploy, Log, Startup, Modules, etc.)
34
+ lib/God/ Process management submodules (ClusterMode, ForkMode, Reload)
35
+ lib/binaries/ CLI implementations
36
+ lib/tools/ Utility functions
37
+ lib/templates/ Config templates & init scripts (systemd, upstart, launchd)
38
+ test/ Tests
39
+ test/programmatic/ Unit tests (Mocha + Should.js)
40
+ test/e2e/ End-to-end tests (bash scripts)
41
+ test/fixtures/ Test fixtures
42
+ types/ TypeScript definitions
43
+ examples/ Example applications
44
+ ```
45
+
46
+ ## PM2 Runtime Files
47
+
48
+ Located at `$HOME/.pm2/`:
49
+ - `pm2.log`, `pm2.pid` — daemon log and PID
50
+ - `rpc.sock`, `pub.sock` — IPC sockets
51
+ - `dump.pm2` — process list dump for resurrection
52
+ - `logs/`, `pids/` — app logs and PIDs
53
+ - `modules/` — installed PM2 modules
54
+
55
+ ## Code Style
56
+
57
+ - **Indentation**: 2 spaces (tabs for Makefiles)
58
+ - **Line endings**: LF
59
+ - **Charset**: UTF-8
60
+ - **Trailing whitespace**: trimmed
61
+ - **Final newline**: yes
62
+ - No linter configured; follow existing patterns
63
+
64
+ ## Test Configuration (Mocha)
65
+
66
+ - Timeout: 10000ms
67
+ - Bail: true (exit on first failure)
68
+ - Retries: 2
69
+ - UI: BDD
70
+ - Exit: true
71
+
72
+ ## Commit Message Convention
73
+
74
+ Prefix commits with: `fix:`, `hotfix:`, `feat:`, `docs:`, `BREAKING:`, `refactor:`, `perf:`, `style:`, `test:`, `chore:`
75
+
76
+ Keep description under 50 chars, lowercase except proper nouns/acronyms.
77
+
78
+ ## CI
79
+
80
+ GitHub Actions on push/PR — tests on Node 16.x and 24.x, plus separate Bun tests. Requires Python 3 and PHP CLI for some e2e tests. 30-minute timeout.
81
+
82
+ ## Key Dependencies
83
+
84
+ - `commander` (CLI), `async`, `pm2-axon`/`pm2-axon-rpc` (IPC), `chokidar` (file watching), `croner` (cron), `pidusage` (process monitoring), `vizion` (VCS), `js-yaml`, `@pm2/io`, `@pm2/agent`
@@ -0,0 +1,124 @@
1
+ # Contributing
2
+
3
+ ## Cloning PM2 development
4
+
5
+ ```bash
6
+ $ git clone https://github.com/Unitech/pm2.git
7
+ $ cd pm2
8
+ $ git checkout development
9
+ $ npm install
10
+ ```
11
+
12
+ I recommend having a pm2 alias pointing to the development version to make it easier to use pm2 development:
13
+
14
+ ```
15
+ $ cd pm2/
16
+ $ echo "alias pm2='`pwd`/bin/pm2'" >> ~/.bashrc
17
+ ```
18
+
19
+ You are now able to use pm2 in dev mode:
20
+
21
+ ```
22
+ $ pm2 update
23
+ $ pm2 ls
24
+ ```
25
+
26
+ ## Project structure
27
+
28
+ ```
29
+ .
30
+ ├── bin // pm2, pmd, pm2-dev, pm2-docker are there
31
+ ├── examples // examples files
32
+ ├── lib // source files
33
+ ├── pres // presentation files
34
+ ├── test // test files
35
+ └── types // TypeScript definition files
36
+ ```
37
+
38
+ ## Modifying the Daemon
39
+
40
+ When you modify the Daemon (lib/Daemon.js, lib/God.js, lib/God/*, lib/Watcher.js), you must restart the pm2 Daemon by doing:
41
+
42
+ ```
43
+ $ pm2 update
44
+ ```
45
+
46
+ ## Commit rules
47
+
48
+ ### Commit message
49
+
50
+ A good commit message should describe what changed and why.
51
+
52
+ It should :
53
+ * contain a short description of the change (preferably 50 characters or less)
54
+ * be entirely in lowercase with the exception of proper nouns, acronyms, and the words that refer to code, like function/variable names
55
+ * be prefixed with one of the following word
56
+ * fix : bug fix
57
+ * hotfix : urgent bug fix
58
+ * feat : new or updated feature
59
+ * docs : documentation updates
60
+ * BREAKING : if commit is a breaking change
61
+ * refactor : code refactoring (no functional change)
62
+ * perf : performance improvement
63
+ * style : UX and display updates
64
+ * test : tests and CI updates
65
+ * chore : updates on build, tools, configuration ...
66
+ * Merge branch : when merging branch
67
+ * Merge pull request : when merging PR
68
+
69
+ ## Tests
70
+
71
+ There are two tests type. Programmatic and Behavioral.
72
+ The main test command is `npm test`
73
+
74
+ ### Programmatic
75
+
76
+ Programmatic tests are runned by doing
77
+
78
+ ```
79
+ $ bash test/pm2_programmatic_tests.sh
80
+ ```
81
+
82
+ This test files are located in test/programmatic/*
83
+
84
+ ### Behavioral
85
+
86
+ Behavioral tests are runned by doing:
87
+
88
+ ```
89
+ $ bash test/e2e.sh
90
+ ```
91
+
92
+ This test files are located in test/e2e/*
93
+
94
+ ## File of interest
95
+
96
+ - `$HOME/.pm2` contain all PM2 related files
97
+ - `$HOME/.pm2/logs` contain all applications logs
98
+ - `$HOME/.pm2/pids` contain all applications pids
99
+ - `$HOME/.pm2/pm2.log` PM2 logs
100
+ - `$HOME/.pm2/pm2.pid` PM2 pid
101
+ - `$HOME/.pm2/rpc.sock` Socket file for remote commands
102
+ - `$HOME/.pm2/pub.sock` Socket file for publishable events
103
+
104
+ ## Generate changelog
105
+
106
+ ### requirements
107
+
108
+ ```
109
+ npm install git-changelog -g
110
+ ```
111
+
112
+ ### usage
113
+
114
+ Edit .changelogrc
115
+ Change "version_name" to the next version to release (example 1.1.2).
116
+ Change "tag" to the latest existing tag (example 1.1.1).
117
+
118
+ Run the following command into pm2 directory
119
+ ```
120
+ git-changelog
121
+ ```
122
+
123
+ It will generate currentTagChangelog.md file.
124
+ Just copy/paste the result into changelog.md