|
1 | | -// Type definitions for pm2 2.7.1 |
| 1 | +// Type definitions for pm2 6.0.8 |
2 | 2 | // Definitions by: João Portela https://www.github.com/jportela |
3 | 3 |
|
4 | 4 | // Exported Methods |
@@ -197,6 +197,120 @@ export function sendDataToProcessId(proc_id: number, packet: object, cb: ErrResu |
197 | 197 | */ |
198 | 198 | export function sendDataToProcessId(packet: {id: number, type: 'process:msg', topic: true, data: object}): void; |
199 | 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 | + |
200 | 314 | // Interfaces |
201 | 315 |
|
202 | 316 | export interface Proc { |
@@ -452,19 +566,152 @@ export interface StartOptions { |
452 | 566 | * @example 'staging' |
453 | 567 | */ |
454 | 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; |
455 | 628 | } |
456 | 629 |
|
457 | 630 | interface ReloadOptions { |
458 | 631 | /** |
459 | | - * (Default: false) If true is passed in, pm2 will reload it’s environment from process.env |
| 632 | + * (Default: false) If true is passed in, pm2 will reload it's environment from process.env |
460 | 633 | * before reloading your process. |
461 | 634 | */ |
462 | 635 | updateEnv?: boolean; |
463 | 636 | } |
464 | 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 | + |
465 | 712 | // Types |
466 | 713 |
|
467 | | -type ProcessStatus = 'online' | 'stopping' | 'stopped' | 'launching' | 'errored' | 'one-launch-status'; |
| 714 | +type ProcessStatus = 'online' | 'stopping' | 'stopped' | 'launching' | 'errored' | 'one-launch-status' | 'waiting_restart'; |
468 | 715 | type Platform = 'ubuntu' | 'centos' | 'redhat' | 'gentoo' | 'systemd' | 'darwin' | 'amazon'; |
469 | 716 |
|
470 | 717 | type ErrCallback = (err: Error) => void; |
|
0 commit comments