From 149e95596e05accf753f2d8ce279b6226c91fc99 Mon Sep 17 00:00:00 2001 From: BluJ Date: Fri, 7 Apr 2023 11:52:44 -0600 Subject: [PATCH] chore: Update the types --- lib/health/checkFns/checkPortListening.ts | 17 ++++++++++++++--- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/health/checkFns/checkPortListening.ts b/lib/health/checkFns/checkPortListening.ts index 2cd28f6..0d736e0 100644 --- a/lib/health/checkFns/checkPortListening.ts +++ b/lib/health/checkFns/checkPortListening.ts @@ -1,4 +1,5 @@ import { Effects } from "../../types"; +import { CheckResult } from "./CheckResult"; export function containsAddress(x: string, port: number) { const readPorts = x .split("\n") @@ -15,12 +16,22 @@ export function containsAddress(x: string, port: number) { * This is used to check if a port is listening on the system. * Used during the health check fn or the check main fn. */ -export async function checkPortListening(effects: Effects, port: number) { +export async function checkPortListening( + effects: Effects, + port: number, + { + error = `Port ${port} is not listening`, + message = `Port ${port} is available`, + } = {} +): Promise { const hasAddress = containsAddress(await effects.shell("cat /proc/net/tcp"), port) || containsAddress(await effects.shell("cat /proc/net/udp"), port); if (hasAddress) { - return; + return { status: "passing", message }; } - throw new Error(`Port ${port} is not listening`); + return { + status: "failing", + message: error, + }; } diff --git a/package-lock.json b/package-lock.json index d05da46..e7e4ebf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "start-sdk", - "version": "0.4.0-lib0.charlie5", + "version": "0.4.0-lib0.charlie7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "start-sdk", - "version": "0.4.0-lib0.charlie5", + "version": "0.4.0-lib0.charlie7", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index b53657d..b10b7ed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "start-sdk", - "version": "0.4.0-lib0.charlie5", + "version": "0.4.0-lib0.charlie7", "description": "For making the patterns that are wanted in making services for the startOS.", "main": "./lib/index.js", "types": "./lib/index.d.ts",