wattpm 3.8.0 → 3.10.0

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.
@@ -5,7 +5,15 @@ import { writeFile } from 'node:fs/promises'
5
5
 
6
6
  export async function pprofStartCommand (logger, args) {
7
7
  try {
8
- const { positionals } = parseArgs(args, {}, false)
8
+ const { positionals, values } = parseArgs(args, {
9
+ type: { type: 'string', short: 't', default: 'cpu' }
10
+ }, false)
11
+
12
+ // Validate profile type
13
+ const type = values.type
14
+ if (type !== 'cpu' && type !== 'heap') {
15
+ return logFatalError(logger, `Invalid profile type: ${type}. Must be 'cpu' or 'heap'.`)
16
+ }
9
17
 
10
18
  const client = new RuntimeApiClient()
11
19
  const [runtime, remainingPositionals] = await getMatchingRuntime(client, positionals)
@@ -14,6 +22,8 @@ export async function pprofStartCommand (logger, args) {
14
22
  // Get application ID from positional arguments or use all applications
15
23
  const applicationId = remainingPositionals[0]
16
24
 
25
+ const options = { intervalMicros: 1000, type }
26
+
17
27
  if (applicationId) {
18
28
  // Start profiling for specific application
19
29
  const application = runtimeApplications.find(s => s.id === applicationId)
@@ -22,14 +32,14 @@ export async function pprofStartCommand (logger, args) {
22
32
  return logFatalError(logger, `Application not found: ${applicationId}`)
23
33
  }
24
34
 
25
- await client.startApplicationProfiling(runtime.pid, applicationId, { intervalMicros: 1000 })
26
- logger.info(`Profiling started for application ${bold(applicationId)}`)
35
+ await client.startApplicationProfiling(runtime.pid, applicationId, options)
36
+ logger.info(`${type.toUpperCase()} profiling started for application ${bold(applicationId)}`)
27
37
  } else {
28
38
  // Start profiling for all applications
29
39
  for (const application of runtimeApplications) {
30
40
  try {
31
- await client.startApplicationProfiling(runtime.pid, application.id, { intervalMicros: 1000 })
32
- logger.info(`Profiling started for application ${bold(application.id)}`)
41
+ await client.startApplicationProfiling(runtime.pid, application.id, options)
42
+ logger.info(`${type.toUpperCase()} profiling started for application ${bold(application.id)}`)
33
43
  } catch (error) {
34
44
  logger.warn(`Failed to start profiling for application ${application.id}: ${error.message}`)
35
45
  }
@@ -50,7 +60,15 @@ export async function pprofStartCommand (logger, args) {
50
60
 
51
61
  export async function pprofStopCommand (logger, args) {
52
62
  try {
53
- const { positionals } = parseArgs(args, {}, false)
63
+ const { positionals, values } = parseArgs(args, {
64
+ type: { type: 'string', short: 't', default: 'cpu' }
65
+ }, false)
66
+
67
+ // Validate profile type
68
+ const type = values.type
69
+ if (type !== 'cpu' && type !== 'heap') {
70
+ return logFatalError(logger, `Invalid profile type: ${type}. Must be 'cpu' or 'heap'.`)
71
+ }
54
72
 
55
73
  const client = new RuntimeApiClient()
56
74
  const [runtime, remainingPositionals] = await getMatchingRuntime(client, positionals)
@@ -60,6 +78,8 @@ export async function pprofStopCommand (logger, args) {
60
78
  const applicationId = remainingPositionals[0]
61
79
  const timestamp = new Date().toISOString().replace(/:/g, '-').replace(/\./g, '-')
62
80
 
81
+ const options = { type }
82
+
63
83
  if (applicationId) {
64
84
  // Stop profiling for specific application
65
85
  const application = runtimeApplications.find(s => s.id === applicationId)
@@ -68,18 +88,18 @@ export async function pprofStopCommand (logger, args) {
68
88
  return logFatalError(logger, `Application not found: ${applicationId}`)
69
89
  }
70
90
 
71
- const profileData = await client.stopApplicationProfiling(runtime.pid, applicationId)
72
- const filename = `pprof-${applicationId}-${timestamp}.pb`
91
+ const profileData = await client.stopApplicationProfiling(runtime.pid, applicationId, options)
92
+ const filename = `pprof-${type}-${applicationId}-${timestamp}.pb`
73
93
  await writeFile(filename, Buffer.from(profileData))
74
- logger.info(`Profiling stopped for application ${bold(applicationId)}, profile saved to ${bold(filename)}`)
94
+ logger.info(`${type.toUpperCase()} profiling stopped for application ${bold(applicationId)}, profile saved to ${bold(filename)}`)
75
95
  } else {
76
96
  // Stop profiling for all applications
77
97
  for (const application of runtimeApplications) {
78
98
  try {
79
- const profileData = await client.stopApplicationProfiling(runtime.pid, application.id)
80
- const filename = `pprof-${application.id}-${timestamp}.pb`
99
+ const profileData = await client.stopApplicationProfiling(runtime.pid, application.id, options)
100
+ const filename = `pprof-${type}-${application.id}-${timestamp}.pb`
81
101
  await writeFile(filename, Buffer.from(profileData))
82
- logger.info(`Profiling stopped for application ${bold(application.id)}, profile saved to ${bold(filename)}`)
102
+ logger.info(`${type.toUpperCase()} profiling stopped for application ${bold(application.id)}, profile saved to ${bold(filename)}`)
83
103
  } catch (error) {
84
104
  logger.warn(`Failed to stop profiling for application ${application.id}: ${error.message}`)
85
105
  }
@@ -113,9 +133,14 @@ export async function pprofCommand (logger, args) {
113
133
 
114
134
  export const help = {
115
135
  pprof: {
116
- usage: 'pprof <start|stop> [id] [application]',
117
- description: 'Profile CPU usage of running application',
118
- options: [],
136
+ usage: 'pprof <start|stop> [id] [application] [options]',
137
+ description: 'Profile CPU or heap usage of running application',
138
+ options: [
139
+ {
140
+ name: '--type, -t',
141
+ description: 'Profile type: "cpu" for CPU wall time (default) or "heap" for heap memory'
142
+ }
143
+ ],
119
144
  args: [
120
145
  {
121
146
  name: 'command',
@@ -126,17 +151,17 @@ export const help = {
126
151
  description:
127
152
  'The process ID or the name of the application (it can be omitted only if there is a single application running)'
128
153
  },
129
- {
130
- name: 'id',
131
- description:
132
- 'The process ID or the name of the application (it can be omitted only if there is a single application running)'
133
- },
134
154
  {
135
155
  name: 'application',
136
156
  description: 'The application ID to profile (if omitted, profiles all applications)'
137
157
  }
138
158
  ],
139
159
  footer:
140
- 'Use "pprof start [application]" to start profiling and "pprof stop [application]" to stop and save profile data.'
160
+ 'Use "pprof start [application]" to start profiling and "pprof stop [application]" to stop and save profile data.\n' +
161
+ 'Examples:\n' +
162
+ ' wattpm pprof start --type=cpu my-app # Start CPU profiling\n' +
163
+ ' wattpm pprof start --type=heap my-app # Start heap profiling\n' +
164
+ ' wattpm pprof stop --type=cpu my-app # Stop CPU profiling\n' +
165
+ ' wattpm pprof stop --type=heap my-app # Stop heap profiling'
141
166
  }
142
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattpm",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "The Node.js Application Server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -29,9 +29,9 @@
29
29
  "pino-pretty": "^13.0.0",
30
30
  "split2": "^4.2.0",
31
31
  "table": "^6.8.2",
32
- "@platformatic/control": "3.8.0",
33
- "@platformatic/runtime": "3.8.0",
34
- "@platformatic/foundation": "3.8.0"
32
+ "@platformatic/control": "3.10.0",
33
+ "@platformatic/foundation": "3.10.0",
34
+ "@platformatic/runtime": "3.10.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "cleaner-spec-reporter": "^0.5.0",
@@ -42,7 +42,7 @@
42
42
  "neostandard": "^0.12.0",
43
43
  "typescript": "^5.5.4",
44
44
  "undici": "^7.0.0",
45
- "@platformatic/node": "3.8.0"
45
+ "@platformatic/node": "3.10.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/wattpm/3.8.0.json",
2
+ "$id": "https://schemas.platformatic.dev/wattpm/3.10.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Runtime Config",
5
5
  "type": "object",
@@ -171,6 +171,40 @@
171
171
  },
172
172
  "additionalProperties": false
173
173
  },
174
+ "dependencies": {
175
+ "type": "array",
176
+ "items": {
177
+ "type": "string"
178
+ },
179
+ "default": []
180
+ },
181
+ "arguments": {
182
+ "type": "array",
183
+ "items": {
184
+ "type": "string"
185
+ }
186
+ },
187
+ "env": {
188
+ "type": "object",
189
+ "additionalProperties": {
190
+ "type": "string"
191
+ }
192
+ },
193
+ "envfile": {
194
+ "type": "string"
195
+ },
196
+ "sourceMaps": {
197
+ "type": "boolean",
198
+ "default": false
199
+ },
200
+ "packageManager": {
201
+ "type": "string",
202
+ "enum": [
203
+ "npm",
204
+ "pnpm",
205
+ "yarn"
206
+ ]
207
+ },
174
208
  "preload": {
175
209
  "anyOf": [
176
210
  {
@@ -186,20 +220,66 @@
186
220
  }
187
221
  ]
188
222
  },
189
- "dependencies": {
190
- "type": "array",
191
- "items": {
192
- "type": "string"
193
- }
194
- },
195
- "arguments": {
196
- "type": "array",
197
- "items": {
198
- "type": "string"
199
- }
200
- },
201
223
  "nodeOptions": {
202
224
  "type": "string"
225
+ },
226
+ "permissions": {
227
+ "type": "object",
228
+ "properties": {
229
+ "fs": {
230
+ "type": "object",
231
+ "properties": {
232
+ "read": {
233
+ "type": "array",
234
+ "items": {
235
+ "type": "string"
236
+ }
237
+ },
238
+ "write": {
239
+ "type": "array",
240
+ "items": {
241
+ "type": "string"
242
+ }
243
+ }
244
+ },
245
+ "additionalProperties": false
246
+ }
247
+ },
248
+ "additionalProperties": false
249
+ },
250
+ "telemetry": {
251
+ "type": "object",
252
+ "properties": {
253
+ "instrumentations": {
254
+ "type": "array",
255
+ "description": "An array of instrumentations loaded if telemetry is enabled",
256
+ "items": {
257
+ "oneOf": [
258
+ {
259
+ "type": "string"
260
+ },
261
+ {
262
+ "type": "object",
263
+ "properties": {
264
+ "package": {
265
+ "type": "string"
266
+ },
267
+ "exportName": {
268
+ "type": "string"
269
+ },
270
+ "options": {
271
+ "type": "object",
272
+ "additionalProperties": true
273
+ }
274
+ },
275
+ "required": [
276
+ "package"
277
+ ]
278
+ }
279
+ ]
280
+ }
281
+ }
282
+ }
203
283
  }
204
284
  }
205
285
  }
@@ -405,6 +485,30 @@
405
485
  "nodeOptions": {
406
486
  "type": "string"
407
487
  },
488
+ "permissions": {
489
+ "type": "object",
490
+ "properties": {
491
+ "fs": {
492
+ "type": "object",
493
+ "properties": {
494
+ "read": {
495
+ "type": "array",
496
+ "items": {
497
+ "type": "string"
498
+ }
499
+ },
500
+ "write": {
501
+ "type": "array",
502
+ "items": {
503
+ "type": "string"
504
+ }
505
+ }
506
+ },
507
+ "additionalProperties": false
508
+ }
509
+ },
510
+ "additionalProperties": false
511
+ },
408
512
  "telemetry": {
409
513
  "type": "object",
410
514
  "properties": {
@@ -641,6 +745,30 @@
641
745
  "nodeOptions": {
642
746
  "type": "string"
643
747
  },
748
+ "permissions": {
749
+ "type": "object",
750
+ "properties": {
751
+ "fs": {
752
+ "type": "object",
753
+ "properties": {
754
+ "read": {
755
+ "type": "array",
756
+ "items": {
757
+ "type": "string"
758
+ }
759
+ },
760
+ "write": {
761
+ "type": "array",
762
+ "items": {
763
+ "type": "string"
764
+ }
765
+ }
766
+ },
767
+ "additionalProperties": false
768
+ }
769
+ },
770
+ "additionalProperties": false
771
+ },
644
772
  "telemetry": {
645
773
  "type": "object",
646
774
  "properties": {
@@ -877,6 +1005,30 @@
877
1005
  "nodeOptions": {
878
1006
  "type": "string"
879
1007
  },
1008
+ "permissions": {
1009
+ "type": "object",
1010
+ "properties": {
1011
+ "fs": {
1012
+ "type": "object",
1013
+ "properties": {
1014
+ "read": {
1015
+ "type": "array",
1016
+ "items": {
1017
+ "type": "string"
1018
+ }
1019
+ },
1020
+ "write": {
1021
+ "type": "array",
1022
+ "items": {
1023
+ "type": "string"
1024
+ }
1025
+ }
1026
+ },
1027
+ "additionalProperties": false
1028
+ }
1029
+ },
1030
+ "additionalProperties": false
1031
+ },
880
1032
  "telemetry": {
881
1033
  "type": "object",
882
1034
  "properties": {
@@ -1691,6 +1843,17 @@
1691
1843
  }
1692
1844
  ]
1693
1845
  }
1846
+ },
1847
+ "timeout": {
1848
+ "anyOf": [
1849
+ {
1850
+ "type": "integer"
1851
+ },
1852
+ {
1853
+ "type": "string"
1854
+ }
1855
+ ],
1856
+ "default": 10000
1694
1857
  }
1695
1858
  },
1696
1859
  "additionalProperties": false
@@ -1873,6 +2036,10 @@
1873
2036
  "type": "number",
1874
2037
  "minimum": 0
1875
2038
  },
2039
+ "gracePeriod": {
2040
+ "type": "number",
2041
+ "minimum": 0
2042
+ },
1876
2043
  "applications": {
1877
2044
  "type": "object",
1878
2045
  "additionalProperties": {