@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.
- package/.claude/settings.local.json +8 -0
- package/.gitattributes +4 -0
- package/.mocharc.js +14 -0
- package/CHANGELOG.md +2416 -0
- package/CLAUDE.md +84 -0
- package/CONTRIBUTING.md +124 -0
- package/GNU-AGPL-3.0.txt +665 -0
- package/LICENSE +1 -0
- package/README.md +248 -0
- package/bin/zm2 +3 -0
- package/bin/zm2-dev +3 -0
- package/bin/zm2-docker +3 -0
- package/bin/zm2-runtime +3 -0
- package/bin/zm2-windows +3 -0
- package/bin/zm2.ps1 +3 -0
- package/bun.lock +421 -0
- package/constants.js +114 -0
- package/index.js +13 -0
- package/lib/API/Configuration.js +212 -0
- package/lib/API/Containerizer.js +335 -0
- package/lib/API/Dashboard.js +459 -0
- package/lib/API/Deploy.js +117 -0
- package/lib/API/Extra.js +775 -0
- package/lib/API/ExtraMgmt/Docker.js +30 -0
- package/lib/API/Log.js +315 -0
- package/lib/API/LogManagement.js +371 -0
- package/lib/API/Modules/LOCAL.js +122 -0
- package/lib/API/Modules/Modularizer.js +148 -0
- package/lib/API/Modules/NPM.js +445 -0
- package/lib/API/Modules/TAR.js +362 -0
- package/lib/API/Modules/flagExt.js +46 -0
- package/lib/API/Modules/index.js +120 -0
- package/lib/API/Monit.js +247 -0
- package/lib/API/Serve.js +343 -0
- package/lib/API/Startup.js +629 -0
- package/lib/API/UX/helpers.js +213 -0
- package/lib/API/UX/index.js +9 -0
- package/lib/API/UX/pm2-describe.js +193 -0
- package/lib/API/UX/pm2-ls-minimal.js +31 -0
- package/lib/API/UX/pm2-ls.js +483 -0
- package/lib/API/Version.js +382 -0
- package/lib/API/interpreter.json +12 -0
- package/lib/API/pm2-plus/PM2IO.js +372 -0
- package/lib/API/pm2-plus/auth-strategies/CliAuth.js +288 -0
- package/lib/API/pm2-plus/auth-strategies/WebAuth.js +187 -0
- package/lib/API/pm2-plus/helpers.js +97 -0
- package/lib/API/pm2-plus/link.js +126 -0
- package/lib/API/pm2-plus/pres/motd +16 -0
- package/lib/API/pm2-plus/pres/motd.update +26 -0
- package/lib/API/pm2-plus/pres/welcome +28 -0
- package/lib/API/pm2-plus/process-selector.js +52 -0
- package/lib/API/schema.json +379 -0
- package/lib/API.js +1931 -0
- package/lib/Client.js +776 -0
- package/lib/Common.js +911 -0
- package/lib/Configuration.js +304 -0
- package/lib/Daemon.js +456 -0
- package/lib/Event.js +37 -0
- package/lib/God/ActionMethods.js +909 -0
- package/lib/God/ClusterMode.js +97 -0
- package/lib/God/ForkMode.js +297 -0
- package/lib/God/Methods.js +265 -0
- package/lib/God/Reload.js +240 -0
- package/lib/God.js +632 -0
- package/lib/HttpInterface.js +76 -0
- package/lib/ProcessContainer.js +305 -0
- package/lib/ProcessContainerBun.js +360 -0
- package/lib/ProcessContainerFork.js +42 -0
- package/lib/ProcessContainerForkBun.js +33 -0
- package/lib/ProcessUtils.js +55 -0
- package/lib/TreeKill.js +118 -0
- package/lib/Utility.js +430 -0
- package/lib/VersionCheck.js +46 -0
- package/lib/Watcher.js +117 -0
- package/lib/Worker.js +169 -0
- package/lib/binaries/CLI.js +1041 -0
- package/lib/binaries/DevCLI.js +183 -0
- package/lib/binaries/Runtime.js +101 -0
- package/lib/binaries/Runtime4Docker.js +192 -0
- package/lib/completion.js +229 -0
- package/lib/completion.sh +40 -0
- package/lib/motd +36 -0
- package/lib/templates/Dockerfiles/Dockerfile-java.tpl +7 -0
- package/lib/templates/Dockerfiles/Dockerfile-nodejs.tpl +8 -0
- package/lib/templates/Dockerfiles/Dockerfile-ruby.tpl +7 -0
- package/lib/templates/ecosystem-es.tpl +24 -0
- package/lib/templates/ecosystem-simple-es.tpl +8 -0
- package/lib/templates/ecosystem-simple.tpl +6 -0
- package/lib/templates/ecosystem.tpl +22 -0
- package/lib/templates/init-scripts/launchd.tpl +35 -0
- package/lib/templates/init-scripts/openrc.tpl +52 -0
- package/lib/templates/init-scripts/pm2-init-amazon.sh +86 -0
- package/lib/templates/init-scripts/rcd-openbsd.tpl +41 -0
- package/lib/templates/init-scripts/rcd.tpl +44 -0
- package/lib/templates/init-scripts/smf.tpl +43 -0
- package/lib/templates/init-scripts/systemd-online.tpl +22 -0
- package/lib/templates/init-scripts/systemd.tpl +22 -0
- package/lib/templates/init-scripts/upstart.tpl +103 -0
- package/lib/templates/logrotate.d/pm2 +10 -0
- package/lib/templates/sample-apps/http-server/README.md +14 -0
- package/lib/templates/sample-apps/http-server/api.js +9 -0
- package/lib/templates/sample-apps/http-server/ecosystem.config.js +14 -0
- package/lib/templates/sample-apps/http-server/package.json +11 -0
- package/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md +45 -0
- package/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js +66 -0
- package/lib/templates/sample-apps/pm2-plus-metrics-actions/ecosystem.config.js +12 -0
- package/lib/templates/sample-apps/pm2-plus-metrics-actions/package.json +11 -0
- package/lib/templates/sample-apps/python-app/README.md +4 -0
- package/lib/templates/sample-apps/python-app/echo.py +7 -0
- package/lib/templates/sample-apps/python-app/ecosystem.config.js +12 -0
- package/lib/templates/sample-apps/python-app/package.json +11 -0
- package/lib/tools/Config.js +248 -0
- package/lib/tools/IsAbsolute.js +20 -0
- package/lib/tools/copydirSync.js +101 -0
- package/lib/tools/deleteFolderRecursive.js +19 -0
- package/lib/tools/find-package-json.js +74 -0
- package/lib/tools/fmt.js +72 -0
- package/lib/tools/isbinaryfile.js +94 -0
- package/lib/tools/json5.js +752 -0
- package/lib/tools/open.js +63 -0
- package/lib/tools/passwd.js +58 -0
- package/lib/tools/promise.min.js +1 -0
- package/lib/tools/sexec.js +55 -0
- package/lib/tools/treeify.js +113 -0
- package/lib/tools/which.js +120 -0
- package/lib/tools/xdg-open +861 -0
- package/package.json +219 -0
- package/paths.js +93 -0
- package/pm2 +11 -0
- package/preinstall.js +24 -0
- package/run.sh +9 -0
- package/types/index.d.ts +722 -0
- package/types/tsconfig.json +14 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,722 @@
|
|
|
1
|
+
// Type definitions for zm2 (forked from pm2 6.0.8)
|
|
2
|
+
// Definitions by: João Portela https://www.github.com/jportela
|
|
3
|
+
|
|
4
|
+
// Exported Methods
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Either connects to a running pm2 daemon (“God”) or launches and daemonizes one.
|
|
8
|
+
* Once launched, the pm2 process will keep running after the script exits.
|
|
9
|
+
* @param errback - Called when finished connecting to or launching the pm2 daemon process.
|
|
10
|
+
*/
|
|
11
|
+
export function connect(errback: ErrCallback): void;
|
|
12
|
+
/**
|
|
13
|
+
* Either connects to a running pm2 daemon (“God”) or launches and daemonizes one.
|
|
14
|
+
* Once launched, the pm2 process will keep running after the script exits.
|
|
15
|
+
* @param noDaemonMode - (Default: false) If true is passed for the first argument
|
|
16
|
+
* pm2 will not be run as a daemon and will die when the related script exits.
|
|
17
|
+
* By default, pm2 stays alive after your script exits.
|
|
18
|
+
* If pm2 is already running, your script will link to the existing daemon but will die once your process exits.
|
|
19
|
+
* @param errback - Called when finished connecting to or launching the pm2 daemon process.
|
|
20
|
+
*/
|
|
21
|
+
export function connect(noDaemonMode:boolean, errback: ErrCallback): void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Starts a script that will be managed by pm2.
|
|
25
|
+
* @param options - Options
|
|
26
|
+
* @param errback - An errback called when the script has been started.
|
|
27
|
+
* The proc parameter will be a pm2 process object.
|
|
28
|
+
*/
|
|
29
|
+
export function start(options: StartOptions, errback: ErrProcCallback): void;
|
|
30
|
+
/**
|
|
31
|
+
* Starts a script that will be managed by pm2.
|
|
32
|
+
* @param jsonConfigFile - The path to a JSON file that can contain the same options as the options parameter.
|
|
33
|
+
* @param errback - An errback called when the script has been started.
|
|
34
|
+
* The proc parameter will be a pm2 process object.
|
|
35
|
+
*/
|
|
36
|
+
export function start(jsonConfigFile: string, errback: ErrProcCallback): void;
|
|
37
|
+
/**
|
|
38
|
+
* Starts a script that will be managed by pm2.
|
|
39
|
+
* @param script - The path of the script to run.
|
|
40
|
+
* @param errback - An errback called when the script has been started.
|
|
41
|
+
* The proc parameter will be a pm2 process object.
|
|
42
|
+
*/
|
|
43
|
+
export function start(script: string , errback: ErrProcCallback): void;
|
|
44
|
+
/**
|
|
45
|
+
* Starts a script that will be managed by pm2.
|
|
46
|
+
* @param script - The path of the script to run.
|
|
47
|
+
* @param options - Options
|
|
48
|
+
* @param errback - An errback called when the script has been started.
|
|
49
|
+
* The proc parameter will be a pm2 process object.
|
|
50
|
+
*/
|
|
51
|
+
export function start(script: string, options: StartOptions, errback: ErrProcCallback): void;
|
|
52
|
+
/**
|
|
53
|
+
* Starts a script that will be managed by pm2.
|
|
54
|
+
* @param script - The path of the script to run.
|
|
55
|
+
* @param jsonConfigFile - The path to a JSON file that can contain the same options as the options parameter.
|
|
56
|
+
* @param errback - An errback called when the script has been started.
|
|
57
|
+
* The proc parameter will be a pm2 process object.
|
|
58
|
+
*/
|
|
59
|
+
export function start(script: string, jsonConfigFile: string, errback: ErrProcCallback): void;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Disconnects from the pm2 daemon.
|
|
63
|
+
*/
|
|
64
|
+
export function disconnect(): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Stops a process but leaves the process meta-data in pm2’s list
|
|
68
|
+
* @param process - Can either be the name as given in the pm2.start options,
|
|
69
|
+
* a process id, or the string “all” to indicate that all scripts should be restarted.
|
|
70
|
+
* @param errback - called when the process is stopped
|
|
71
|
+
*/
|
|
72
|
+
export function stop(process: string|number, errback: ErrProcCallback): void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Stops and restarts the process.
|
|
76
|
+
* @param process - Can either be the name as given in the pm2.start options,
|
|
77
|
+
* a process id, or the string “all” to indicate that all scripts should be restarted.
|
|
78
|
+
* @param errback - called when the process is restarted
|
|
79
|
+
*/
|
|
80
|
+
export function restart(process: string|number, errback: ErrProcCallback): void;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Stops the process and removes it from pm2’s list.
|
|
84
|
+
* The process will no longer be accessible by its name
|
|
85
|
+
* @param process - Can either be the name as given in the pm2.start options,
|
|
86
|
+
* a process id, or the string “all” to indicate that all scripts should be restarted.
|
|
87
|
+
* @param errback - called when the process is deleted
|
|
88
|
+
*/
|
|
89
|
+
declare function del(process: string|number, errback: ErrProcCallback): void;
|
|
90
|
+
// have to use this construct because `delete` is a reserved word
|
|
91
|
+
export {del as delete};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Zero-downtime rolling restart. At least one process will be kept running at
|
|
95
|
+
* all times as each instance is restarted individually.
|
|
96
|
+
* Only works for scripts started in cluster mode.
|
|
97
|
+
* @param process - Can either be the name as given in the pm2.start options,
|
|
98
|
+
* a process id, or the string “all” to indicate that all scripts should be restarted.
|
|
99
|
+
* @param errback - called when the process is reloaded
|
|
100
|
+
*/
|
|
101
|
+
export function reload(process: string|number, errback: ErrProcCallback): void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Zero-downtime rolling restart. At least one process will be kept running at
|
|
105
|
+
* all times as each instance is restarted individually.
|
|
106
|
+
* Only works for scripts started in cluster mode.
|
|
107
|
+
* @param process - Can either be the name as given in the pm2.start options,
|
|
108
|
+
* a process id, or the string “all” to indicate that all scripts should be restarted.
|
|
109
|
+
* @param options - An object containing configuration
|
|
110
|
+
* @param options.updateEnv - (Default: false) If true is passed in, pm2 will reload it’s
|
|
111
|
+
* environment from process.env before reloading your process.
|
|
112
|
+
* @param errback - called when the process is reloaded
|
|
113
|
+
*/
|
|
114
|
+
export function reload(process: string|number, options: ReloadOptions, errback: ErrProcCallback): void;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Kills the pm2 daemon (same as pm2 kill). Note that when the daemon is killed, all its
|
|
118
|
+
* processes are also killed. Also note that you still have to explicitly disconnect
|
|
119
|
+
* from the daemon even after you kill it.
|
|
120
|
+
* @param errback
|
|
121
|
+
*/
|
|
122
|
+
export function killDaemon(errback: ErrProcDescCallback): void;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns various information about a process: eg what stdout/stderr and pid files are used.
|
|
126
|
+
* @param process - Can either be the name as given in the pm2.start options,
|
|
127
|
+
* a process id, or the string “all” to indicate that all scripts should be restarted.
|
|
128
|
+
* @param errback
|
|
129
|
+
*/
|
|
130
|
+
export function describe(process: string|number, errback: ErrProcDescsCallback): void;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Gets the list of running processes being managed by pm2.
|
|
134
|
+
* @param errback
|
|
135
|
+
*/
|
|
136
|
+
export function list(errback: ErrProcDescsCallback): void;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Writes the process list to a json file at the path in the DUMP_FILE_PATH environment variable
|
|
140
|
+
* (“~/.pm2/dump.pm2” by default).
|
|
141
|
+
* @param errback
|
|
142
|
+
*/
|
|
143
|
+
export function dump(errback: ErrResultCallback): void;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Flushes the logs.
|
|
147
|
+
* @param process - Can either be the name as given in the pm2.start options,
|
|
148
|
+
* a process id, or the string “all” to indicate that all scripts should be restarted.
|
|
149
|
+
* @param errback
|
|
150
|
+
*/
|
|
151
|
+
export function flush(process: number|string, errback: ErrResultCallback): void;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @param errback
|
|
155
|
+
*/
|
|
156
|
+
export function dump(errback: ErrResultCallback): void;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Rotates the log files. The new log file will have a higher number
|
|
160
|
+
* in it (the default format being ${process.name}-${out|err}-${number}.log).
|
|
161
|
+
* @param errback
|
|
162
|
+
*/
|
|
163
|
+
export function reloadLogs(errback: ErrResultCallback): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Opens a message bus.
|
|
167
|
+
* @param errback The bus will be an Axon Sub Emitter object used to listen to and send events.
|
|
168
|
+
*/
|
|
169
|
+
export function launchBus(errback: ErrBusCallback): void;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @param signal
|
|
173
|
+
* @param process - Can either be the name as given in the pm2.start options,
|
|
174
|
+
* a process id, or the string “all” to indicate that all scripts should be restarted.
|
|
175
|
+
* @param errback
|
|
176
|
+
*/
|
|
177
|
+
export function sendSignalToProcessName(signal:string|number, process: number|string, errback: ErrResultCallback): void;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* - Registers the script as a process that will start on machine boot. The current process list will be dumped and saved for resurrection on reboot.
|
|
181
|
+
* @param platform
|
|
182
|
+
* @param errback
|
|
183
|
+
*/
|
|
184
|
+
export function startup(platform: Platform, errback: ErrResultCallback): void;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* - Send an set of data as object to a specific process
|
|
188
|
+
* @param proc_id
|
|
189
|
+
* @param packet
|
|
190
|
+
* @param cb
|
|
191
|
+
*/
|
|
192
|
+
export function sendDataToProcessId(proc_id: number, packet: object, cb: ErrResultCallback): void;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* - Send an set of data as object to a specific process
|
|
196
|
+
* @param packet {id: number, type: 'process:msg', topic: true, data: object}
|
|
197
|
+
*/
|
|
198
|
+
export function sendDataToProcessId(packet: {id: number, type: 'process:msg', topic: true, data: object}): void;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Launch system monitoring (CPU, Memory usage)
|
|
202
|
+
* @param errback - Called when monitoring is launched
|
|
203
|
+
*/
|
|
204
|
+
export function launchSysMonitoring(errback?: ErrCallback): void;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Profile CPU or Memory usage
|
|
208
|
+
* @param type - 'cpu' for CPU profiling, 'mem' for memory profiling
|
|
209
|
+
* @param time - Duration in seconds (default: 10)
|
|
210
|
+
* @param errback - Called when profiling is complete
|
|
211
|
+
*/
|
|
212
|
+
export function profile(type: 'cpu' | 'mem', time?: number, errback?: ErrCallback): void;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Get process environment variables
|
|
216
|
+
* @param app_id - Process name or id
|
|
217
|
+
* @param errback - Called with environment variables
|
|
218
|
+
*/
|
|
219
|
+
export function env(app_id: string | number, errback?: ErrCallback): void;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Get process PID
|
|
223
|
+
* @param app_name - Process name (optional, returns all PIDs if not provided)
|
|
224
|
+
* @param errback - Called with PID information
|
|
225
|
+
*/
|
|
226
|
+
export function getPID(app_name?: string, errback?: ErrProcCallback): void;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Trigger a custom action on a process
|
|
230
|
+
* @param pm_id - Process id
|
|
231
|
+
* @param action_name - Name of the action to trigger
|
|
232
|
+
* @param params - Parameters to pass to the action
|
|
233
|
+
* @param errback - Called when action completes
|
|
234
|
+
*/
|
|
235
|
+
export function trigger(pm_id: string | number, action_name: string, params?: any, errback?: ErrCallback): void;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Inspect a process (debugging)
|
|
239
|
+
* @param app_name - Process name
|
|
240
|
+
* @param errback - Called with inspect information
|
|
241
|
+
*/
|
|
242
|
+
export function inspect(app_name: string, errback?: ErrCallback): void;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Serve static files
|
|
246
|
+
* @param path - Path to serve files from
|
|
247
|
+
* @param port - Port number (default: 8080)
|
|
248
|
+
* @param options - Serve options
|
|
249
|
+
* @param errback - Called when server starts
|
|
250
|
+
*/
|
|
251
|
+
export function serve(path?: string, port?: number, options?: ServeOptions, errback?: ErrCallback): void;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Install a PM2 module
|
|
255
|
+
* @param module_name - Name of the module to install
|
|
256
|
+
* @param options - Installation options
|
|
257
|
+
* @param errback - Called when installation completes
|
|
258
|
+
*/
|
|
259
|
+
export function install(module_name: string, options?: InstallOptions, errback?: ErrCallback): void;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Uninstall a PM2 module
|
|
263
|
+
* @param module_name - Name of the module to uninstall
|
|
264
|
+
* @param errback - Called when uninstallation completes
|
|
265
|
+
*/
|
|
266
|
+
export function uninstall(module_name: string, errback?: ErrCallback): void;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Send line to process stdin
|
|
270
|
+
* @param pm_id - Process id
|
|
271
|
+
* @param line - Line to send
|
|
272
|
+
* @param separator - Line separator (default: '\n')
|
|
273
|
+
* @param errback - Called when line is sent
|
|
274
|
+
*/
|
|
275
|
+
export function sendLineToStdin(pm_id: string | number, line: string, separator?: string, errback?: ErrCallback): void;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Attach to process logs
|
|
279
|
+
* @param pm_id - Process id
|
|
280
|
+
* @param separator - Log separator
|
|
281
|
+
* @param errback - Called when attached
|
|
282
|
+
*/
|
|
283
|
+
export function attach(pm_id: string | number, separator?: string, errback?: ErrCallback): void;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Get PM2 configuration value
|
|
287
|
+
* @param key - Configuration key (optional, returns all config if not provided)
|
|
288
|
+
* @param errback - Called with configuration value
|
|
289
|
+
*/
|
|
290
|
+
export function get(key?: string, errback?: ErrCallback): void;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Set PM2 configuration value
|
|
294
|
+
* @param key - Configuration key
|
|
295
|
+
* @param value - Configuration value
|
|
296
|
+
* @param errback - Called when value is set
|
|
297
|
+
*/
|
|
298
|
+
export function set(key: string, value: any, errback?: ErrCallback): void;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Set multiple PM2 configuration values
|
|
302
|
+
* @param values - Configuration values as string
|
|
303
|
+
* @param errback - Called when values are set
|
|
304
|
+
*/
|
|
305
|
+
export function multiset(values: string, errback?: ErrCallback): void;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Unset PM2 configuration value
|
|
309
|
+
* @param key - Configuration key to unset
|
|
310
|
+
* @param errback - Called when value is unset
|
|
311
|
+
*/
|
|
312
|
+
export function unset(key: string, errback?: ErrCallback): void;
|
|
313
|
+
|
|
314
|
+
// Interfaces
|
|
315
|
+
|
|
316
|
+
export interface Proc {
|
|
317
|
+
name?: string;
|
|
318
|
+
vizion?: boolean;
|
|
319
|
+
autorestart?: boolean;
|
|
320
|
+
exec_mode?: string;
|
|
321
|
+
exec_interpreter?: string;
|
|
322
|
+
pm_exec_path?: string;
|
|
323
|
+
pm_cwd?: string;
|
|
324
|
+
instances?: number;
|
|
325
|
+
node_args?: string[];
|
|
326
|
+
pm_out_log_path?: string;
|
|
327
|
+
pm_err_log_path?: string;
|
|
328
|
+
pm_pid_path?: string;
|
|
329
|
+
status?: string;
|
|
330
|
+
pm_uptime?: number;
|
|
331
|
+
axm_actions?: any[];
|
|
332
|
+
axm_monitor?: any;
|
|
333
|
+
axm_dynamic?: any;
|
|
334
|
+
vizion_running?: boolean;
|
|
335
|
+
created_at?: number;
|
|
336
|
+
pm_id?: number;
|
|
337
|
+
restart_time?: number;
|
|
338
|
+
unstable_restarts?: number;
|
|
339
|
+
started_inside?: boolean;
|
|
340
|
+
command?: Command;
|
|
341
|
+
versioning?: any;
|
|
342
|
+
exit_code?: number;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export interface Command {
|
|
346
|
+
locked?: boolean;
|
|
347
|
+
metadata?: any;
|
|
348
|
+
started_at?: any;
|
|
349
|
+
finished_at?: any;
|
|
350
|
+
error?: any;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* An object with information about the process.
|
|
355
|
+
*/
|
|
356
|
+
export interface ProcessDescription {
|
|
357
|
+
/**
|
|
358
|
+
* The name given in the original start command.
|
|
359
|
+
*/
|
|
360
|
+
name?: string;
|
|
361
|
+
/**
|
|
362
|
+
* The pid of the process.
|
|
363
|
+
*/
|
|
364
|
+
pid?: number;
|
|
365
|
+
/**
|
|
366
|
+
* The pid for the pm2 God daemon process.
|
|
367
|
+
*/
|
|
368
|
+
pm_id?: number;
|
|
369
|
+
monit?: Monit;
|
|
370
|
+
/**
|
|
371
|
+
* The list of path variables in the process’s environment
|
|
372
|
+
*/
|
|
373
|
+
pm2_env?: Pm2Env;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
interface Monit {
|
|
377
|
+
/**
|
|
378
|
+
* The number of bytes the process is using.
|
|
379
|
+
*/
|
|
380
|
+
memory?: number;
|
|
381
|
+
/**
|
|
382
|
+
* The percent of CPU being used by the process at the moment.
|
|
383
|
+
*/
|
|
384
|
+
cpu?: number;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* The list of path variables in the process’s environment
|
|
389
|
+
*/
|
|
390
|
+
interface Pm2Env {
|
|
391
|
+
/**
|
|
392
|
+
* The working directory of the process.
|
|
393
|
+
*/
|
|
394
|
+
pm_cwd?: string;
|
|
395
|
+
/**
|
|
396
|
+
* The stdout log file path.
|
|
397
|
+
*/
|
|
398
|
+
pm_out_log_path?: string;
|
|
399
|
+
/**
|
|
400
|
+
* The stderr log file path.
|
|
401
|
+
*/
|
|
402
|
+
pm_err_log_path?: string;
|
|
403
|
+
/**
|
|
404
|
+
* The interpreter used.
|
|
405
|
+
*/
|
|
406
|
+
exec_interpreter?: string;
|
|
407
|
+
/**
|
|
408
|
+
* The uptime of the process.
|
|
409
|
+
*/
|
|
410
|
+
pm_uptime?: number;
|
|
411
|
+
/**
|
|
412
|
+
* The number of unstable restarts the process has been through.
|
|
413
|
+
*/
|
|
414
|
+
unstable_restarts?: number;
|
|
415
|
+
restart_time?: number;
|
|
416
|
+
status?: ProcessStatus;
|
|
417
|
+
/**
|
|
418
|
+
* The number of running instances.
|
|
419
|
+
*/
|
|
420
|
+
instances?: number | 'max';
|
|
421
|
+
/**
|
|
422
|
+
* The path of the script being run in this process.
|
|
423
|
+
*/
|
|
424
|
+
pm_exec_path?: string;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export interface StartOptions {
|
|
428
|
+
/**
|
|
429
|
+
* Enable or disable auto start after process added (default: true).
|
|
430
|
+
*/
|
|
431
|
+
autostart?: boolean;
|
|
432
|
+
/**
|
|
433
|
+
* Enable or disable auto restart after process failure (default: true).
|
|
434
|
+
*/
|
|
435
|
+
autorestart?: boolean;
|
|
436
|
+
/**
|
|
437
|
+
* List of exit codes that should allow the process to stop (skip autorestart).
|
|
438
|
+
*/
|
|
439
|
+
stop_exit_codes?: number[];
|
|
440
|
+
/**
|
|
441
|
+
* An arbitrary name that can be used to interact with (e.g. restart) the process
|
|
442
|
+
* later in other commands. Defaults to the script name without its extension
|
|
443
|
+
* (eg “testScript” for “testScript.js”)
|
|
444
|
+
*/
|
|
445
|
+
name?: string;
|
|
446
|
+
/**
|
|
447
|
+
* The path of the script to run
|
|
448
|
+
*/
|
|
449
|
+
script?: string;
|
|
450
|
+
/**
|
|
451
|
+
* A string or array of strings composed of arguments to pass to the script.
|
|
452
|
+
*/
|
|
453
|
+
args?: string | string[];
|
|
454
|
+
/**
|
|
455
|
+
* A string or array of strings composed of arguments to call the interpreter process with.
|
|
456
|
+
* Eg “–harmony” or [”–harmony”,”–debug”]. Only applies if interpreter is something other
|
|
457
|
+
* than “none” (its “node” by default).
|
|
458
|
+
*/
|
|
459
|
+
interpreter_args?: string | string[];
|
|
460
|
+
/**
|
|
461
|
+
* The working directory to start the process with.
|
|
462
|
+
*/
|
|
463
|
+
cwd?: string;
|
|
464
|
+
/**
|
|
465
|
+
* (Default: “~/.pm2/logs/app_name-out.log”) The path to a file to append stdout output to.
|
|
466
|
+
* Can be the same file as error.
|
|
467
|
+
*/
|
|
468
|
+
output?: string;
|
|
469
|
+
/**
|
|
470
|
+
* (Default: “~/.pm2/logs/app_name-error.err”) The path to a file to append stderr output to. Can be the same file as output.
|
|
471
|
+
*/
|
|
472
|
+
error?: string;
|
|
473
|
+
/**
|
|
474
|
+
* The display format for log timestamps (eg “YYYY-MM-DD HH:mm Z”). The format is a moment display format.
|
|
475
|
+
*/
|
|
476
|
+
log_date_format?: string;
|
|
477
|
+
/**
|
|
478
|
+
* Default: “~/.pm2/logs/~/.pm2/pids/app_name-id.pid”)
|
|
479
|
+
* The path to a file to write the pid of the started process. The file will be overwritten.
|
|
480
|
+
* Note that the file is not used in any way by pm2 and so the user is free to manipulate or
|
|
481
|
+
* remove that file at any time. The file will be deleted when the process is stopped or the daemon killed.
|
|
482
|
+
*/
|
|
483
|
+
pid?: string;
|
|
484
|
+
/**
|
|
485
|
+
* The minimum uptime of the script before it’s considered successfully started.
|
|
486
|
+
*/
|
|
487
|
+
min_uptime?: number;
|
|
488
|
+
/**
|
|
489
|
+
* The maximum number of times in a row a script will be restarted if it exits in less than min_uptime.
|
|
490
|
+
*/
|
|
491
|
+
max_restarts?: number;
|
|
492
|
+
/**
|
|
493
|
+
* If sets and script’s memory usage goes about the configured number, pm2 restarts the script.
|
|
494
|
+
* Uses human-friendly suffixes: ‘K’ for kilobytes, ‘M’ for megabytes, ‘G’ for gigabytes’, etc. Eg “150M”.
|
|
495
|
+
*/
|
|
496
|
+
max_memory_restart?: number | string;
|
|
497
|
+
/**
|
|
498
|
+
* Arguments to pass to the interpreter
|
|
499
|
+
*/
|
|
500
|
+
node_args?: string | string[];
|
|
501
|
+
/**
|
|
502
|
+
* Prefix logs with time
|
|
503
|
+
*/
|
|
504
|
+
time?: boolean;
|
|
505
|
+
/**
|
|
506
|
+
* This will make PM2 listen for that event. In your application you will need to add process.send('ready');
|
|
507
|
+
* when you want your application to be considered as ready.
|
|
508
|
+
*/
|
|
509
|
+
wait_ready?: boolean;
|
|
510
|
+
/**
|
|
511
|
+
* (Default: 1600)
|
|
512
|
+
* The number of milliseconds to wait after a stop or restart command issues a SIGINT signal to kill the
|
|
513
|
+
* script forceably with a SIGKILL signal.
|
|
514
|
+
*/
|
|
515
|
+
kill_timeout?: number;
|
|
516
|
+
/**
|
|
517
|
+
* (Default: 0) Number of millseconds to wait before restarting a script that has exited.
|
|
518
|
+
*/
|
|
519
|
+
restart_delay?: number;
|
|
520
|
+
/**
|
|
521
|
+
* (Default: “node”) The interpreter for your script (eg “python”, “ruby”, “bash”, etc).
|
|
522
|
+
* The value “none” will execute the ‘script’ as a binary executable.
|
|
523
|
+
*/
|
|
524
|
+
interpreter?: string;
|
|
525
|
+
/**
|
|
526
|
+
* (Default: ‘fork’) If sets to ‘cluster’, will enable clustering
|
|
527
|
+
* (running multiple instances of the script).
|
|
528
|
+
*/
|
|
529
|
+
exec_mode?: string;
|
|
530
|
+
/**
|
|
531
|
+
* (Default: 1) How many instances of script to create. Only relevant in exec_mode ‘cluster’.
|
|
532
|
+
*/
|
|
533
|
+
instances?: number;
|
|
534
|
+
/**
|
|
535
|
+
* (Default: false) If true, merges the log files for all instances of script into one stderr log
|
|
536
|
+
* and one stdout log. Only applies in ‘cluster’ mode. For example, if you have 4 instances of
|
|
537
|
+
* ‘test.js’ started via pm2, normally you would have 4 stdout log files and 4 stderr log files,
|
|
538
|
+
* but with this option set to true you would only have one stdout file and one stderr file.
|
|
539
|
+
*/
|
|
540
|
+
merge_logs?: boolean;
|
|
541
|
+
/**
|
|
542
|
+
* If set to true, the application will be restarted on change of the script file.
|
|
543
|
+
*/
|
|
544
|
+
watch?: boolean|string[];
|
|
545
|
+
/**
|
|
546
|
+
* (Default: false) By default, pm2 will only start a script if that script isn’t
|
|
547
|
+
* already running (a script is a path to an application, not the name of an application
|
|
548
|
+
* already running). If force is set to true, pm2 will start a new instance of that script.
|
|
549
|
+
*/
|
|
550
|
+
force?: boolean;
|
|
551
|
+
ignore_watch?: string[];
|
|
552
|
+
cron?: any;
|
|
553
|
+
execute_command?: any;
|
|
554
|
+
write?: any;
|
|
555
|
+
source_map_support?: any;
|
|
556
|
+
disable_source_map_support?: any;
|
|
557
|
+
/**
|
|
558
|
+
* The environment variables to pass on to the process.
|
|
559
|
+
*/
|
|
560
|
+
env?: { [key: string]: string; };
|
|
561
|
+
/**
|
|
562
|
+
* NameSpace for the process
|
|
563
|
+
* @default 'default'
|
|
564
|
+
* @example 'production'
|
|
565
|
+
* @example 'development'
|
|
566
|
+
* @example 'staging'
|
|
567
|
+
*/
|
|
568
|
+
namespace?: string;
|
|
569
|
+
/**
|
|
570
|
+
* (Default: false) Exponential backoff restart delay in milliseconds.
|
|
571
|
+
* When enabled, PM2 will progressively increase restart delays after failures.
|
|
572
|
+
*/
|
|
573
|
+
exp_backoff_restart_delay?: number;
|
|
574
|
+
/**
|
|
575
|
+
* Timeout for application to be ready after reload (in milliseconds).
|
|
576
|
+
*/
|
|
577
|
+
listen_timeout?: number;
|
|
578
|
+
/**
|
|
579
|
+
* (Default: false) If true, shutdown the process using process.send('shutdown') instead of process.kill().
|
|
580
|
+
*/
|
|
581
|
+
shutdown_with_message?: boolean;
|
|
582
|
+
/**
|
|
583
|
+
* Environment variable name that gets incremented for each cluster instance.
|
|
584
|
+
*/
|
|
585
|
+
increment_var?: string;
|
|
586
|
+
/**
|
|
587
|
+
* Name of the environment variable holding the instance ID.
|
|
588
|
+
* @default 'NODE_APP_INSTANCE'
|
|
589
|
+
*/
|
|
590
|
+
instance_var?: string;
|
|
591
|
+
/**
|
|
592
|
+
* Filter out specific environment variables from the process.
|
|
593
|
+
* Can be true to filter all, or array/string of specific variables.
|
|
594
|
+
*/
|
|
595
|
+
filter_env?: boolean | string | string[];
|
|
596
|
+
/**
|
|
597
|
+
* (Default: false) Disable logs output.
|
|
598
|
+
*/
|
|
599
|
+
disable_logs?: boolean;
|
|
600
|
+
/**
|
|
601
|
+
* Log output type.
|
|
602
|
+
*/
|
|
603
|
+
log_type?: string;
|
|
604
|
+
/**
|
|
605
|
+
* (Default: false) Enable container mode.
|
|
606
|
+
*/
|
|
607
|
+
container?: boolean;
|
|
608
|
+
/**
|
|
609
|
+
* (Default: false) Distribution mode for Docker.
|
|
610
|
+
*/
|
|
611
|
+
dist?: boolean;
|
|
612
|
+
/**
|
|
613
|
+
* Docker image name.
|
|
614
|
+
*/
|
|
615
|
+
image_name?: string;
|
|
616
|
+
/**
|
|
617
|
+
* Node.js version for Docker container.
|
|
618
|
+
*/
|
|
619
|
+
node_version?: string;
|
|
620
|
+
/**
|
|
621
|
+
* (Default: false) Fresh install for Docker.
|
|
622
|
+
*/
|
|
623
|
+
fresh?: boolean;
|
|
624
|
+
/**
|
|
625
|
+
* (Default: false) Docker daemon mode.
|
|
626
|
+
*/
|
|
627
|
+
dockerdaemon?: boolean;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
interface ReloadOptions {
|
|
631
|
+
/**
|
|
632
|
+
* (Default: false) If true is passed in, pm2 will reload it's environment from process.env
|
|
633
|
+
* before reloading your process.
|
|
634
|
+
*/
|
|
635
|
+
updateEnv?: boolean;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Options for serving static files
|
|
640
|
+
*/
|
|
641
|
+
export interface ServeOptions {
|
|
642
|
+
/**
|
|
643
|
+
* (Default: false) Single Page Application mode
|
|
644
|
+
*/
|
|
645
|
+
spa?: boolean;
|
|
646
|
+
/**
|
|
647
|
+
* Basic authentication username
|
|
648
|
+
*/
|
|
649
|
+
basic_auth_username?: string;
|
|
650
|
+
/**
|
|
651
|
+
* Basic authentication password
|
|
652
|
+
*/
|
|
653
|
+
basic_auth_password?: string;
|
|
654
|
+
/**
|
|
655
|
+
* Monitor URL path
|
|
656
|
+
*/
|
|
657
|
+
monitor?: string;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Options for Docker operations
|
|
662
|
+
*/
|
|
663
|
+
export interface DockerOptions {
|
|
664
|
+
/**
|
|
665
|
+
* Docker image name
|
|
666
|
+
*/
|
|
667
|
+
imageName?: string;
|
|
668
|
+
/**
|
|
669
|
+
* Node.js version to use
|
|
670
|
+
*/
|
|
671
|
+
nodeVersion?: string;
|
|
672
|
+
/**
|
|
673
|
+
* (Default: false) Fresh installation
|
|
674
|
+
*/
|
|
675
|
+
fresh?: boolean;
|
|
676
|
+
/**
|
|
677
|
+
* (Default: false) Force operation
|
|
678
|
+
*/
|
|
679
|
+
force?: boolean;
|
|
680
|
+
/**
|
|
681
|
+
* (Default: false) Docker daemon mode
|
|
682
|
+
*/
|
|
683
|
+
dockerdaemon?: boolean;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Options for module installation
|
|
688
|
+
*/
|
|
689
|
+
export interface InstallOptions {
|
|
690
|
+
/**
|
|
691
|
+
* (Default: false) Install from tarball
|
|
692
|
+
*/
|
|
693
|
+
tarball?: boolean;
|
|
694
|
+
/**
|
|
695
|
+
* (Default: true) Perform installation
|
|
696
|
+
*/
|
|
697
|
+
install?: boolean;
|
|
698
|
+
/**
|
|
699
|
+
* (Default: false) Docker mode
|
|
700
|
+
*/
|
|
701
|
+
docker?: boolean;
|
|
702
|
+
/**
|
|
703
|
+
* (Default: false) Use v1 API
|
|
704
|
+
*/
|
|
705
|
+
v1?: boolean;
|
|
706
|
+
/**
|
|
707
|
+
* (Default: false) Safe mode installation
|
|
708
|
+
*/
|
|
709
|
+
safe?: boolean | number;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// Types
|
|
713
|
+
|
|
714
|
+
type ProcessStatus = 'online' | 'stopping' | 'stopped' | 'launching' | 'errored' | 'one-launch-status' | 'waiting_restart';
|
|
715
|
+
type Platform = 'ubuntu' | 'centos' | 'redhat' | 'gentoo' | 'systemd' | 'darwin' | 'amazon';
|
|
716
|
+
|
|
717
|
+
type ErrCallback = (err: Error) => void;
|
|
718
|
+
type ErrProcCallback = (err: Error, proc: Proc) => void;
|
|
719
|
+
type ErrProcDescCallback = (err: Error, processDescription: ProcessDescription) => void;
|
|
720
|
+
type ErrProcDescsCallback = (err: Error, processDescriptionList: ProcessDescription[]) => void;
|
|
721
|
+
type ErrResultCallback = (err: Error, result: any) => void;
|
|
722
|
+
type ErrBusCallback = (err: Error, bus: any) => void;
|