@platformatic/control 1.27.0 → 1.28.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.
- package/help/logs.txt +1 -1
- package/lib/errors.js +3 -1
- package/lib/runtime-api-client.js +38 -4
- package/package.json +6 -6
package/help/logs.txt
CHANGED
|
@@ -10,7 +10,7 @@ Options:
|
|
|
10
10
|
* `-n, --name <string>` - The name of the runtime.
|
|
11
11
|
* `-l, --level <string>` - The pino log level to stream. Default is `info`.
|
|
12
12
|
* `-s, --service <string>` - The name of the service to stream logs from.
|
|
13
|
-
* `--pretty
|
|
13
|
+
* `--pretty <boolean>` - Pretty print the logs. Default is `true`.
|
|
14
14
|
|
|
15
15
|
If `--service` is not specified, the command will stream logs from all services.
|
|
16
16
|
|
package/lib/errors.js
CHANGED
|
@@ -17,5 +17,7 @@ module.exports = {
|
|
|
17
17
|
FailedToStopRuntime: createError(`${ERROR_PREFIX}_FAILED_TO_STOP_RUNTIME`, 'Failed to stop the runtime %s.'),
|
|
18
18
|
FailedToReloadRuntime: createError(`${ERROR_PREFIX}_FAILED_TO_RELOAD_RUNTIME`, 'Failed to reload the runtime %s.'),
|
|
19
19
|
FailedToGetRuntimeConfig: createError(`${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_CONFIG`, 'Failed to get runtime config %s.'),
|
|
20
|
-
FailedToGetRuntimeServiceConfig: createError(`${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_SERVICE_CONFIG`, 'Failed to get runtime service config %s.')
|
|
20
|
+
FailedToGetRuntimeServiceConfig: createError(`${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_SERVICE_CONFIG`, 'Failed to get runtime service config %s.'),
|
|
21
|
+
FailedToGetRuntimeHistoryLogs: createError(`${ERROR_PREFIX}_FAILED_TO_GET_HISTORY_LOGS`, 'Failed to get history logs %s.'),
|
|
22
|
+
FailedToGetRuntimeLogIndexes: createError(`${ERROR_PREFIX}_FAILED_TO_GET_HISTORY_LOGS_COUNT`, 'Failed to get history logs count %s.')
|
|
21
23
|
}
|
|
@@ -181,28 +181,62 @@ class RuntimeApiClient {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
getRuntimeLiveMetricsStream (pid) {
|
|
185
185
|
const socketPath = this.#getSocketPathFromPid(pid)
|
|
186
186
|
|
|
187
187
|
const protocol = platform() === 'win32' ? 'ws+unix:' : 'ws+unix://'
|
|
188
|
-
const webSocketUrl = protocol + socketPath + ':/api/v1/
|
|
188
|
+
const webSocketUrl = protocol + socketPath + ':/api/v1/metrics/live'
|
|
189
189
|
const webSocketStream = new WebSocketStream(webSocketUrl)
|
|
190
190
|
this.#webSockets.add(webSocketStream.ws)
|
|
191
191
|
|
|
192
192
|
return webSocketStream
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
getRuntimeLiveLogsStream (pid, startLogIndex) {
|
|
196
196
|
const socketPath = this.#getSocketPathFromPid(pid)
|
|
197
197
|
|
|
198
198
|
const protocol = platform() === 'win32' ? 'ws+unix:' : 'ws+unix://'
|
|
199
|
-
const
|
|
199
|
+
const query = startLogIndex ? `?start=${startLogIndex}` : ''
|
|
200
|
+
const webSocketUrl = protocol + socketPath + ':/api/v1/logs/live' + query
|
|
200
201
|
const webSocketStream = new WebSocketStream(webSocketUrl)
|
|
201
202
|
this.#webSockets.add(webSocketStream.ws)
|
|
202
203
|
|
|
203
204
|
return webSocketStream
|
|
204
205
|
}
|
|
205
206
|
|
|
207
|
+
async getRuntimeLogsStream (pid, logsId) {
|
|
208
|
+
const client = this.#getUndiciClient(pid)
|
|
209
|
+
|
|
210
|
+
const { statusCode, body } = await client.request({
|
|
211
|
+
path: '/api/v1/logs/' + logsId,
|
|
212
|
+
method: 'GET'
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
if (statusCode !== 200) {
|
|
216
|
+
const error = await body.text()
|
|
217
|
+
throw new errors.FailedToGetRuntimeHistoryLogs(error)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return body
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async getRuntimeLogIndexes (pid) {
|
|
224
|
+
const client = this.#getUndiciClient(pid)
|
|
225
|
+
|
|
226
|
+
const { statusCode, body } = await client.request({
|
|
227
|
+
path: '/api/v1/logs/indexes',
|
|
228
|
+
method: 'GET'
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
if (statusCode !== 200) {
|
|
232
|
+
const error = await body.text()
|
|
233
|
+
throw new errors.FailedToGetRuntimeLogIndexes(error)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const { indexes } = await body.json()
|
|
237
|
+
return indexes
|
|
238
|
+
}
|
|
239
|
+
|
|
206
240
|
async injectRuntime (pid, serviceId, options) {
|
|
207
241
|
const client = this.#getUndiciClient(pid)
|
|
208
242
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/control",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"description": "Platformatic Control",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -18,22 +18,22 @@
|
|
|
18
18
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"borp": "^0.10.0",
|
|
21
|
-
"desm": "^1.3.
|
|
21
|
+
"desm": "^1.3.1",
|
|
22
22
|
"execa": "^8.0.1",
|
|
23
23
|
"snazzy": "^9.0.0",
|
|
24
24
|
"split2": "^4.2.0",
|
|
25
25
|
"standard": "^17.1.0",
|
|
26
|
-
"tsd": "^0.30.
|
|
27
|
-
"@platformatic/runtime": "1.
|
|
26
|
+
"tsd": "^0.30.7",
|
|
27
|
+
"@platformatic/runtime": "1.28.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@fastify/error": "^3.4.1",
|
|
31
31
|
"commist": "^3.2.0",
|
|
32
32
|
"help-me": "^5.0.0",
|
|
33
|
-
"pino": "^8.
|
|
33
|
+
"pino": "^8.19.0",
|
|
34
34
|
"pino-pretty": "^10.3.1",
|
|
35
35
|
"table": "^6.8.1",
|
|
36
|
-
"undici": "^6.
|
|
36
|
+
"undici": "^6.9.0",
|
|
37
37
|
"ws": "^8.16.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|