Skip to content

Commit

Permalink
Tear down telemetry in the correct order
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Apr 22, 2024
1 parent ea5acf2 commit be13e20
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _For detailed documentation, visit [pup.56k.guru](https://pup.56k.guru)._
To install Pup, open your terminal and execute the following command:

```bash
deno run -Ar jsr:@pup/pup@1.0.0-rc.30 setup --channel prerelease
deno run -Ar jsr:@pup/pup@1.0.0-rc.31 setup --channel prerelease
```

This command downloads the latest version of Pup and installs it on your system. The `--channel prerelease` option is included as there is no stable version of Pup yet. Read more abour release
Expand Down
2 changes: 1 addition & 1 deletion application.meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

const Application = {
name: "pup",
version: "1.0.0-rc.30",
version: "1.0.0-rc.31",
url: "jsr:@pup/pup@$VERSION",
canary_url: "https://raw.githubusercontent.com/Hexagon/pup/main/pup.ts",
deno: null, /* Minimum stable version of Deno required to run Pup (without --unstable-* flags) */
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pup/pup",
"version": "1.0.0-rc.30",
"version": "1.0.0-rc.31",

"exports": {
".": "./pup.ts",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": "Universal Process Manager"
},
"substitute": {
"$PUP_VERSION": "1.0.0-rc.30"
"$PUP_VERSION": "1.0.0-rc.31"
},
"top_links": [
{
Expand Down
4 changes: 4 additions & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ nav_order: 13

All notable changes to this project will be documented in this section.

## [1.0.0-rc.31] - 2024-04-23

- fix(telementry): Tear down in correct order

## [1.0.0-rc.30] - 2024-04-22

- fix(rest): Add `/log` to the rest api
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/telemetry/task-with-telemetry-1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// See docs/examples/telemetry/README.md for full documentation on telemetry, including using the IPC
// - Pin this to the latest version of pup, or include in import map
import { PupTelemetry } from "jsr:@pup/pup@1.0.0-rc.30/telemetry"
import { PupTelemetry } from "jsr:@pup/pup@1.0.0-rc.31/telemetry"
const telemetry = new PupTelemetry(1)

// The task
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/telemetry/task-with-telemetry-2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// See docs/examples/telemetry/README.md for full documentation on telemetry, including using the IPC
// - Pin this to the latest version of pup, or include in import map
import { PupTelemetry } from "jsr:@pup/pup@1.0.0-rc.30/telemetry"
import { PupTelemetry } from "jsr:@pup/pup@1.0.0-rc.31/telemetry"
const telemetry = new PupTelemetry(1)

// The task
Expand Down
35 changes: 19 additions & 16 deletions telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,26 @@ export class PupTelemetry {

if (pupTempPath && (await isDir(pupTempPath)) && pupProcessId) {
const ipcPath = `${pupTempPath}/.${pupProcessId}.ipc` // Process-specific IPC path
this.ipc = new FileIPC(ipcPath)

// Read incoming messages
for await (const messages of this.ipc.receiveData()) {
// Break out of the loop if aborted
if (this.aborted) break

if (messages.length > 0) {
// Process messages and emit events
for (const message of messages) {
try {
if (message.data) {
const parsedMessage = JSON.parse(message.data)
this.events.emit(parsedMessage.event, parsedMessage.eventData)
// Break out of the loop if aborted
if (!this.aborted) {
this.ipc = new FileIPC(ipcPath)

// Read incoming messages
for await (const messages of this.ipc.receiveData()) {
// Break out of the loop if aborted
if (this.aborted) break

if (messages.length > 0) {
// Process messages and emit events
for (const message of messages) {
try {
if (message.data) {
const parsedMessage = JSON.parse(message.data)
this.events.emit(parsedMessage.event, parsedMessage.eventData)
}
} catch (_e) {
// Ignore errors in message parsing and processing
}
} catch (_e) {
// Ignore errors in message parsing and processing
}
}
}
Expand Down

0 comments on commit be13e20

Please sign in to comment.