-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathpm2.ts
796 lines (785 loc) · 17.1 KB
/
pm2.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
import { filepaths } from "@fig/autocomplete-generators";
const generators: Record<string, Fig.Generator> = {
jsonFileGenerator: filepaths({ extensions: ["json"] }),
};
const appArg: Fig.Arg = {
name: "app name",
};
const keyArg: Fig.Arg = {
name: "key",
};
const nameArg: Fig.Arg = {
name: "name",
};
const numberArg: Fig.Arg = {
name: "number",
};
const pathArg: Fig.Arg = {
name: "path",
template: "filepaths",
};
const platformArg: Fig.Arg = {
name: "platform",
isOptional: true,
suggestions: ["systemd", "upstart", "launchd", "rcd"],
};
const jsonFileArg: Fig.Arg = {
name: "json",
generators: generators.jsonFileGenerator,
};
const sharedOptions: Fig.Option[] = [
{
name: ["-V", "--version"],
description: "Outputs the version number",
},
{
name: "-v",
description: "Gets version",
},
{
name: ["-s", "--silent"],
description: "Hides all messages",
},
{
name: ["-m", "--mini-list"],
description: "Displays a compacted list without formatting",
},
{
name: ["-f", "--force"],
description: "Forces actions",
},
{
name: "--disable-logs",
description: "Do not write logs",
},
{
name: ["-n", "--name"],
description: "Sets a name for script",
args: nameArg,
},
{
name: ["-i", "--instances"],
description:
"Launches [number] instances (for networked app)(load balanced)",
args: numberArg,
},
{
name: "--parallel",
description: "Number of parallel actions (for restart/reload)",
args: numberArg,
},
{
name: ["-l", "--log"],
description: "Specifies entire log file (error and out are both included)",
args: {
...pathArg,
isOptional: true,
},
},
{
name: ["-o", "--output"],
description: "Specifies out log file",
args: pathArg,
},
{
name: ["-e", "--error"],
description: "Specifies error log file",
args: pathArg,
},
{
name: ["-p", "--pid"],
description: "Specify pid file",
args: {
name: "pid",
template: "filepaths",
},
},
{
name: ["-k", "--kill-timeout"],
description: "Delays before sending final SIGKILL signal to process",
args: {
name: "delay",
},
},
{
name: "--listen-timeout",
description: "Listen timeout on application reload",
args: {
name: "delay",
},
},
{
name: "--max-memory-restart",
description:
"Specify max memory amount used to autorestart (in octet or use syntax like 100M)",
args: {
name: "memory",
},
},
{
name: "--restart-delay",
description: "Specify a delay between restarts (in milliseconds)",
args: {
name: "delay",
},
},
{
name: "--env",
description: "Specify environment to get specific env variables",
args: {
name: "Environment Name",
},
},
{
name: "--log-type",
description: "Specify log output style (raw by default, json optional)",
args: {
name: "type",
default: "raw",
},
},
{
name: ["-x", "--execute-command"],
description: "Execute a program using fork system",
},
{
name: "--max-restarts",
description: "Only Restart the script COUNT times",
args: {
name: "Count",
isOptional: true,
},
},
{
name: ["-u", "--user"],
description: "Defines user when generating startup script",
args: {
name: "username",
},
},
{
name: "--uid",
description: "Runs target script with <uid> rights",
args: {
name: "uid",
},
},
{
name: "--gid",
description: "Runs target script with <gid> rights",
args: {
name: "gid",
},
},
{
name: "--cwd",
description: "Runs target script as <username>",
args: pathArg,
},
{
name: "--hp",
description: "Defines home path when generating startup script",
args: {
name: "home path",
template: "folders",
},
},
{
name: "--wait-ip",
description:
"Overrides systemd script to wait for full internet connectivity to launch pm2",
},
{
name: "--service-name",
description: "Defines service name when generating startup script",
args: nameArg,
},
{
name: ["-c", "--cron"],
description: "Restarts a running process based on a cron pattern",
args: {
name: "Cron Pattern",
},
},
{
name: ["-w", "--write"],
description: "Writes configuration in local folder",
},
{
name: "--interpreter",
description:
"The interpreter pm2 should use for executing app (bash, python…)",
args: {
name: "interpreter",
},
},
{
name: "--interpreter-args",
description: "Interprets options (alias of –node-args)",
args: {
name: "Arguments",
},
},
{
name: "--log-date-format",
description: "Adds custom prefix timestamp to logs",
args: {
name: "Date Format",
},
},
{
name: "--no-daemon",
description:
"Runs pm2 daemon in the foreground if it doesn’t exist already",
},
{
name: ["-a", "--update-env"],
description: "Updates environment on restart/reload (-a <=> apply)",
},
{ name: "–-source-map-support", description: "Force source map support" },
{
name: "–-only",
description: "With json declaration, allow to only act on one application",
args: appArg,
},
{
name: "–-disable-source-map-support",
description: "Force source map support",
},
{
name: "–-wait-ready",
description: "Asks pm2 to wait for ready event from your app",
},
{
name: "–-merge-logs",
description:
"Merges logs from different instances but keep error and out separated",
},
{
name: "–-watch",
description: "Watches application folder for changes (default: )",
args: {
name: "paths",
template: ["folders"],
isVariadic: true,
},
},
{
name: "–-ignore-watch",
description: "Folder/files to be ignored watching",
args: {
name: "Folder or Files",
template: ["folders", "filepaths"],
isVariadic: true,
},
},
{
name: "–-node-args",
description: "Space delimited arguments to pass to node in cluster mode",
args: {
name: "Node Args",
description: "–node-args=`–debug=7001 –trace-deprecation`",
},
},
{ name: "–-no-color", description: "Skip colors" },
{
name: "–-no-vizion",
description: "Starts an app without vizion feature (versioning control)",
},
{
name: "–-no-autorestart",
description: "Starts an app without automatic restart",
},
{
name: "–-no-treekill",
description: "Only kills the main process, not detached children",
},
{ name: "–-no-pmx", description: "Starts an app without apm" },
{ name: "–-no-automation", description: "Starts an app without apm" },
{ name: "–-trace", description: "Enables transaction tracing with km" },
{
name: "–-disable-trace",
description: "Disables transaction tracing with km",
},
{
name: "–-attach",
description: "Attaches logging after your start/restart/stop/reload",
},
{
name: "–-sort",
description: "Sort process according to field’s name",
args: {
name: "field name",
description: "Field_name:sort",
},
},
{ name: "–-v8", description: "Enables v8 data collecting" },
{
name: "–-event-loop-inspector",
description: "Enables event-loop-inspector dump in apm",
},
{
name: "–-deep-monitoring",
description:
"Enables all monitoring tools (equivalent to –v8 –event-loop-inspector –trace)",
},
{ name: ["-h", "–-help"], description: "Outputs usage information" },
];
const completionSpec: Fig.Spec = {
name: "pm2",
description: "Daemon process manager",
subcommands: [
{
name: "start",
description: "Starts and daemonizes an app",
options: sharedOptions,
args: {
name: "file, json, stdin, app name, pm id, etc",
},
},
{
name: "trigger",
description: "Deploy your json",
args: [
{
name: "Proc Name",
},
{
name: "Action Name",
},
{
name: "Params",
isOptional: true,
},
],
},
{
name: "deploy",
description: "Deploy your json",
args: {
name: "File or environment",
template: "filepaths",
},
},
{
name: "startOrRestart",
description: "Start or restart JSON file",
args: jsonFileArg,
},
{
name: "startOrReload",
description: "Start or gracefully reload JSON file",
args: jsonFileArg,
},
{
name: "pid",
description: "Return pid of the specified app or all",
args: {
...appArg,
isOptional: true,
},
},
{
name: "startOrGracefulReload",
description: "Start or gracefully reolad JSON file",
args: jsonFileArg,
},
{
name: "stop",
description: "Stop a process",
options: sharedOptions,
args: {
name: "id, name, all, json, stdin, etc",
},
},
{
name: "restart",
description: "Restart a process",
options: sharedOptions,
args: {
name: "id, name, all, json, stdin, etc",
},
},
{
name: "scale",
description:
"Scale up/down a process in cluster mode depending on the `number` param",
args: [appArg, numberArg],
},
{
name: "snapshot",
description: "Snapshot PM2 memory",
},
{
name: "profile",
description: "Profile CPU",
args: {
name: "command",
},
},
{
name: "reload",
description: "Reload processes (for apps using HTTP/HTTPS)",
args: {
name: "name or all",
},
},
{
name: "gracefulReload",
description:
"Gracefully reload a process. Send a “shutdown” message to close all connections",
args: {
name: "name or all",
},
},
{
name: "id",
description: "Get process id by name",
args: nameArg,
},
{
name: "delete",
description: "Stops and deletes a process from pm2 process list",
args: {
name: "name, id, script, all, json, stdin, etc",
},
},
{
name: "sendSignal",
description: "Send a system signal to the target process",
args: [
{
name: "signal",
},
{
name: "pm2_id or name",
},
],
},
{
name: "ping",
description: "Ping pm2 daemon - if not it will launch up",
},
{
name: "updatePM2",
description: "Update in-memory PM2 with local PM2",
},
{
name: "update",
description: "(alias) update in-memory PM2 with local PM2",
},
{
name: ["install", "module:install"],
description: "Install or update a module and run it forever",
options: sharedOptions,
args: {
name: "module or git://",
isOptional: true,
},
},
{
name: "module:generate",
description: "Generate a sample module in current folder",
args: {
...appArg,
isOptional: true,
},
},
{
name: ["uninstall", "module:uninstall"],
description: "Stop and uninstall a module",
args: {
name: "module",
},
},
{
name: ["publish", "module:publish"],
description: "Publish the module you are currently on",
},
{
name: "set",
description: "Sets the specified config",
args: [
{
...keyArg,
isOptional: true,
},
{
name: "value",
isOptional: true,
},
],
},
{
name: "multiset",
description: "Multiset eg `key1 val1 key2 val2`",
args: {
name: "key value",
isVariadic: true,
},
},
{
name: "get",
description: "Get value for the specified key",
args: {
...keyArg,
isOptional: true,
},
},
{
name: "conf",
description: "Get / set module config values",
args: [
{
...keyArg,
isOptional: true,
},
{
name: "value",
isOptional: true,
},
],
},
{
name: "config",
description: "Get / set module config values",
args: [
keyArg,
{
name: "value",
isOptional: true,
},
],
},
{
name: "unset",
description: "Clears the specified config key",
args: keyArg,
},
{
name: "report",
description:
"Give a full pm2 report for https://github.com/Unitech/pm2/issues",
},
{
name: ["link", "interact"],
description: "Linking action to keymetrics.io",
options: sharedOptions,
args: [
{
name: "secret",
isOptional: true,
},
{
name: "public",
isOptional: true,
},
{
...nameArg,
isOptional: true,
},
],
},
{
name: "unlink",
description: "Linking action to keymetrics.io",
},
{
name: "unmonitor",
description: "Unmonitor target process",
args: nameArg,
},
{
name: "monitor",
description: "<Unm>onitor target process",
args: nameArg,
},
{
name: "open",
description: "Open dashboard in browser",
},
{
name: "register",
description: "Create an account on keymetrics",
},
{
name: "login",
description: "Login to keymetrics and link current PM2",
},
{
name: "web",
description: "Launch a health API on 0.0.0.0:9615",
},
{
name: ["dump", "save"],
description: "Dump all processes for resurrecting them later",
},
{
name: "send",
description: "Send stdin to pm id",
args: [
{
name: "pm id",
},
{
name: "line",
},
],
},
{
name: "attach",
description: "Attach stdin/stdout to application identified by pm id",
args: [
{
name: "pm id",
},
{
name: "command",
isOptional: true,
},
],
},
{
name: "resurrect",
description: "Resurrect previously dumped processes",
},
{
name: "unstartup",
description: "Disable and clear auto startup",
args: platformArg,
},
{
name: "startup",
description: "Setup script for pm2 at boot",
args: platformArg,
},
{
name: "logrotate",
description: "Copy default logrotate configuration",
},
{
name: ["ecosystem", "init"],
description: "Generate a process conf file",
args: {
name: "mode",
isOptional: true,
suggestions: ["null", "simple"],
},
},
{
name: "reset",
description: "Reset counters for process",
args: {
name: "name, id, or all",
},
},
{
name: "describe",
description: "Describe all parameters of a process id",
args: {
name: "id",
},
},
{
name: ["desc", "info", "show"],
description: "(alias) Describe all parameters of a process id",
args: {
name: "id",
},
},
{
name: ["list", "ls"],
description: "List all processes",
},
{
name: ["l", "ps", "status"],
description: "(alias) list all processes",
},
{
name: "jlist",
description: "List all processes in JSON format",
},
{
name: "prettylist",
description: "Print json in a prettified JSON",
},
{
name: "monit",
description: "Launch termcaps monitoring",
},
{
name: "imonit",
description: "Launch legacy termcaps monitoring",
},
{
name: ["dashboard", "dash"],
description: "Launch dashboard with monitoring and logs",
},
{
name: "flush",
description: "Flush logs",
},
{
name: "reloadLogs",
description: "Reload all logs",
},
{
name: "logs",
description: "Stream logs logs file",
options: sharedOptions,
args: {
name: "id or name",
},
},
{
name: "kill",
description: "Kill daemon",
},
{
name: "pull",
description: "Updates repository for a given app",
args: [
nameArg,
{
name: "commit id",
isOptional: true,
},
],
},
{
name: "forward",
description: "Updates repository to the next commit for a given app",
args: nameArg,
},
{
name: "backward",
description:
"Downgrades repository to the previous commit for a given app",
args: nameArg,
},
{
name: "gc",
description: "Force PM2 to trigger garbage collection",
},
{
name: "deepUpdate",
description: "Performs a deep update of PM2",
},
{
name: ["serve", "expose"],
description: "Serves a directory over http via port",
args: [
{
name: "path",
isOptional: true,
},
{
name: "port",
isOptional: true,
},
],
},
],
options: sharedOptions,
};
export default completionSpec;