@platformatic/control 2.27.1 → 2.28.1-alpha.1

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/control.js CHANGED
@@ -5,6 +5,7 @@ const { parseArgs } = require('node:util')
5
5
  const commist = require('commist')
6
6
  const helpMe = require('help-me')
7
7
 
8
+ const runtimeMetricsCommand = require('./lib/metrics')
8
9
  const getRuntimesCommand = require('./lib/ps')
9
10
  const getRuntimesEnvCommand = require('./lib/env')
10
11
  const getRuntimeServicesCommand = require('./lib/services')
@@ -27,6 +28,7 @@ program.register('stop', wrapCommand(stopRuntimeCommand))
27
28
  program.register('reload', wrapCommand(reloadRuntimeCommand))
28
29
  program.register('restart', wrapCommand(restartRuntimeCommand))
29
30
  program.register('logs', wrapCommand(streamRuntimeLogsCommand))
31
+ program.register('metrics', wrapCommand(runtimeMetricsCommand))
30
32
  program.register('env', wrapCommand(getRuntimesEnvCommand))
31
33
  program.register('services', wrapCommand(getRuntimeServicesCommand))
32
34
  program.register('config', wrapCommand(getRuntimeConfigCommand))
@@ -0,0 +1,14 @@
1
+ Get metrics from the platformatic runtime application.
2
+
3
+ ``` bash
4
+ $ platformatic ctl metrics
5
+ ```
6
+
7
+ Options:
8
+
9
+ * `-p, --pid <number>` - The process id of the runtime.
10
+ * `-f, --format <string>` - The format of the metrics, which should be either `text` or `json` (default to `json`).
11
+
12
+ If `--pid` is not specified, the command will get metrics from the first available matching runtime.
13
+
14
+ To see the list of all available control commands, run `platformatic ctl help`.
package/lib/metrics.js ADDED
@@ -0,0 +1,25 @@
1
+ 'use strict'
2
+
3
+ const { parseArgs } = require('node:util')
4
+
5
+ const RuntimeApiClient = require('./runtime-api-client')
6
+
7
+ async function runtimeMetricsCommand (argv) {
8
+ const args = parseArgs({
9
+ args: argv,
10
+ options: {
11
+ pid: { type: 'string', short: 'p' },
12
+ format: { type: 'string', short: 'f', default: 'json' }
13
+ },
14
+ strict: false,
15
+ }).values
16
+
17
+ const client = new RuntimeApiClient()
18
+ const runtimePid = args.pid || (await client.getMatchingRuntime([])).pid
19
+ const metrics = await client.getRuntimeMetrics(runtimePid, { format: args.format })
20
+ const result = args.format === 'text' ? metrics : JSON.stringify(metrics, null, 2)
21
+ console.log(result)
22
+ await client.close()
23
+ }
24
+
25
+ module.exports = runtimeMetricsCommand
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/control",
3
- "version": "2.27.1",
3
+ "version": "2.28.1-alpha.1",
4
4
  "description": "Platformatic Control",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -20,13 +20,13 @@
20
20
  "borp": "^0.19.0",
21
21
  "desm": "^1.3.1",
22
22
  "eslint": "9",
23
- "execa": "^8.0.1",
23
+ "execa": "^9.0.0",
24
24
  "neostandard": "^0.12.0",
25
25
  "split2": "^4.2.0",
26
26
  "tsd": "^0.31.0",
27
27
  "typescript": "^5.5.4",
28
- "@platformatic/runtime": "2.27.1",
29
- "@platformatic/service": "2.27.1"
28
+ "@platformatic/service": "2.28.1-alpha.1",
29
+ "@platformatic/runtime": "2.28.1-alpha.1"
30
30
  },
31
31
  "dependencies": {
32
32
  "@fastify/error": "^4.0.0",
@@ -37,7 +37,7 @@
37
37
  "table": "^6.8.1",
38
38
  "undici": "^7.0.0",
39
39
  "ws": "^8.16.0",
40
- "@platformatic/utils": "2.27.1"
40
+ "@platformatic/utils": "2.28.1-alpha.1"
41
41
  },
42
42
  "scripts": {
43
43
  "test": "pnpm run lint && pnpm run unit",