mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 20:24:47 +00:00
chore: Update the types
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Effects } from "../../types";
|
import { Effects } from "../../types";
|
||||||
|
import { CheckResult } from "./CheckResult";
|
||||||
export function containsAddress(x: string, port: number) {
|
export function containsAddress(x: string, port: number) {
|
||||||
const readPorts = x
|
const readPorts = x
|
||||||
.split("\n")
|
.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.
|
* This is used to check if a port is listening on the system.
|
||||||
* Used during the health check fn or the check main fn.
|
* 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<CheckResult> {
|
||||||
const hasAddress =
|
const hasAddress =
|
||||||
containsAddress(await effects.shell("cat /proc/net/tcp"), port) ||
|
containsAddress(await effects.shell("cat /proc/net/tcp"), port) ||
|
||||||
containsAddress(await effects.shell("cat /proc/net/udp"), port);
|
containsAddress(await effects.shell("cat /proc/net/udp"), port);
|
||||||
if (hasAddress) {
|
if (hasAddress) {
|
||||||
return;
|
return { status: "passing", message };
|
||||||
}
|
}
|
||||||
throw new Error(`Port ${port} is not listening`);
|
return {
|
||||||
|
status: "failing",
|
||||||
|
message: error,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "start-sdk",
|
"name": "start-sdk",
|
||||||
"version": "0.4.0-lib0.charlie5",
|
"version": "0.4.0-lib0.charlie7",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "start-sdk",
|
"name": "start-sdk",
|
||||||
"version": "0.4.0-lib0.charlie5",
|
"version": "0.4.0-lib0.charlie7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iarna/toml": "^2.2.5",
|
"@iarna/toml": "^2.2.5",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "start-sdk",
|
"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.",
|
"description": "For making the patterns that are wanted in making services for the startOS.",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user