Skip to content

Commit

Permalink
Initialize pup in the correct order to make telemetry work
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Apr 22, 2024
1 parent 2293847 commit 4e11008
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 10 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.29 setup --channel prerelease
deno run -Ar jsr:@pup/pup@1.0.0-rc.30 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.29",
version: "1.0.0-rc.30",
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.29",
"version": "1.0.0-rc.30",

"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.29"
"$PUP_VERSION": "1.0.0-rc.30"
},
"top_links": [
{
Expand Down
1 change: 1 addition & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this section.
- fix(rest): Add `/log` to the rest api
- chore(docs): Add Rest API docs.
- fix(core): Reset restart count on any kind of manual start
- fix(telemetry): Initialize in the correct order

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

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@$PUP_VERSION/telemetry"
import { PupTelemetry } from "jsr:@pup/pup@1.0.0-rc.30/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@$PUP_VERSION/telemetry"
import { PupTelemetry } from "jsr:@pup/pup@1.0.0-rc.30/telemetry"
const telemetry = new PupTelemetry(1)

// The task
Expand Down
6 changes: 3 additions & 3 deletions lib/core/pup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ class Pup {
await this.status.cleanup()
}

public init = () => {
public init = async () => {
// Initialize api
this.api()
await this.api()

// Attach logger to events
this.logger.attach((severity: string, category: string, text: string, process?: ProcessConfiguration): boolean => {
Expand Down Expand Up @@ -302,7 +302,7 @@ class Pup {
// Initialize rest api
try {
this.restApi = new RestApi(this, this.configuration.api?.hostname, parseInt(port!, 10), secret)
await this.restApi.start()
this.restApi.start()
} catch (e) {
this.logger.error("rest", `An error occured while inizializing the rest api: ${e.message}`)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Runner extends BaseRunner {
// - PUP_API_HOSTNAME
env.PUP_API_HOSTNAME = this.pup.configuration.api?.hostname || DEFAULT_REST_API_HOSTNAME
// - PUP_API_PORT
if (this.pup.port?.fromCache()) env.PUP_API_PORT = this.pup.port.fromCache()
if (this.pup.port?.load()) env.PUP_API_PORT = this.pup.port.fromCache()!
// - PUP_API_TOKEN
if (this.pup.secret?.load()) env.PUP_API_TOKEN = await GenerateToken(await this.pup.secret?.load(), { consumer: "telemetry-" + this.processConfig.id }, new Date().getTime() + 365 * 24 * 60 * 60)

Expand Down
14 changes: 14 additions & 0 deletions versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
"canary_url": "https://raw.githubusercontent.com/Hexagon/pup/main/pup.ts",
"stable": [],
"prerelease": [
{
"version": "1.0.0-rc.30",
"url": "jsr:@pup/pup@1.0.0-rc.30",
"deno": null,
"deno_unstable": "1.42.0",
"default_permissions": [
"--allow-env",
"--allow-read",
"--allow-write",
"--allow-sys=loadavg,systemMemoryInfo,osUptime,osRelease,uid,gid",
"--allow-net",
"--allow-run"
]
},
{
"version": "1.0.0-rc.29",
"url": "jsr:@pup/pup@1.0.0-rc.29",
Expand Down

0 comments on commit 4e11008

Please sign in to comment.