@platformatic/control 1.25.0 → 1.27.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/lib/logs.js CHANGED
@@ -32,10 +32,10 @@ async function streamRuntimeLogsCommand (argv) {
32
32
  const logLevelNumber = pinoLogLevels[args.level]
33
33
  const prettify = prettyFactory()
34
34
 
35
- const logsStream = client.getRuntimeLogsStream(runtime.pid)
35
+ const logsStream = client.getRuntimeLiveLogsStream(runtime.pid)
36
36
 
37
37
  logsStream.on('data', (data) => {
38
- const logs = data.toString().split('\n')
38
+ const logs = data.toString().split('\n').filter(Boolean)
39
39
 
40
40
  for (let log of logs) {
41
41
  try {
package/lib/ps.js CHANGED
@@ -55,7 +55,7 @@ function formatRuntimeTime (timeSeconds) {
55
55
  const tableConfig = {
56
56
  border: getBorderCharacters('void'),
57
57
  columnDefault: {
58
- paddingLeft: 1,
58
+ paddingLeft: 0,
59
59
  paddingRight: 1
60
60
  },
61
61
  drawHorizontalLine: () => false
@@ -9,7 +9,7 @@ const { Client } = require('undici')
9
9
  const WebSocket = require('ws')
10
10
  const errors = require('./errors.js')
11
11
 
12
- const PLATFORMATIC_TMP_DIR = join(tmpdir(), 'platformatic', 'pids')
12
+ const PLATFORMATIC_TMP_DIR = join(tmpdir(), 'platformatic', 'runtimes')
13
13
  const PLATFORMATIC_PIPE_PREFIX = '\\\\.\\pipe\\platformatic-'
14
14
 
15
15
  class RuntimeApiClient {
@@ -181,11 +181,22 @@ class RuntimeApiClient {
181
181
  }
182
182
  }
183
183
 
184
- getRuntimeLogsStream (pid) {
184
+ getRuntimeLiveLogsStream (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/logs'
188
+ const webSocketUrl = protocol + socketPath + ':/api/v1/logs/live'
189
+ const webSocketStream = new WebSocketStream(webSocketUrl)
190
+ this.#webSockets.add(webSocketStream.ws)
191
+
192
+ return webSocketStream
193
+ }
194
+
195
+ getRuntimeHistoryLogsStream (pid) {
196
+ const socketPath = this.#getSocketPathFromPid(pid)
197
+
198
+ const protocol = platform() === 'win32' ? 'ws+unix:' : 'ws+unix://'
199
+ const webSocketUrl = protocol + socketPath + ':/api/v1/logs/history'
189
200
  const webSocketStream = new WebSocketStream(webSocketUrl)
190
201
  this.#webSockets.add(webSocketStream.ws)
191
202
 
@@ -232,7 +243,7 @@ class RuntimeApiClient {
232
243
  if (platform() === 'win32') {
233
244
  return PLATFORMATIC_PIPE_PREFIX + pid
234
245
  }
235
- return join(PLATFORMATIC_TMP_DIR, `${pid}.sock`)
246
+ return join(PLATFORMATIC_TMP_DIR, pid.toString(), 'socket')
236
247
  }
237
248
 
238
249
  async #getUnixRuntimePIDs () {
@@ -241,11 +252,10 @@ class RuntimeApiClient {
241
252
  } catch {
242
253
  return []
243
254
  }
244
- const socketNames = await readdir(PLATFORMATIC_TMP_DIR)
255
+ const runtimeDirs = await readdir(PLATFORMATIC_TMP_DIR)
245
256
  const runtimePIDs = []
246
- for (const socketName of socketNames) {
247
- const runtimePID = socketName.replace('.sock', '')
248
- runtimePIDs.push(parseInt(runtimePID))
257
+ for (const runtimeDirName of runtimeDirs) {
258
+ runtimePIDs.push(parseInt(runtimeDirName))
249
259
  }
250
260
  return runtimePIDs
251
261
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/control",
3
- "version": "1.25.0",
3
+ "version": "1.27.0",
4
4
  "description": "Platformatic Control",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -17,14 +17,14 @@
17
17
  },
18
18
  "homepage": "https://github.com/platformatic/platformatic#readme",
19
19
  "devDependencies": {
20
- "borp": "^0.9.0",
20
+ "borp": "^0.10.0",
21
21
  "desm": "^1.3.0",
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
26
  "tsd": "^0.30.4",
27
- "@platformatic/runtime": "1.25.0"
27
+ "@platformatic/runtime": "1.27.0"
28
28
  },
29
29
  "dependencies": {
30
30
  "@fastify/error": "^3.4.1",