mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-31 04:33:40 +00:00
chore: Add in the converter for the newest of the builder.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { Effects } from "../../types";
|
||||
import { parseCommand } from "../../util/parseCommand";
|
||||
import { CheckResult } from "./CheckResult";
|
||||
export function containsAddress(x: string, port: number) {
|
||||
const readPorts = x
|
||||
@@ -26,14 +25,8 @@ export async function checkPortListening(
|
||||
} = {}
|
||||
): Promise<CheckResult> {
|
||||
const hasAddress =
|
||||
containsAddress(
|
||||
await effects.runCommand(parseCommand("cat /proc/net/tcp")),
|
||||
port
|
||||
) ||
|
||||
containsAddress(
|
||||
await effects.runCommand(parseCommand("cat /proc/net/udp")),
|
||||
port
|
||||
);
|
||||
containsAddress(await effects.runCommand(`cat /proc/net/tcp`), port) ||
|
||||
containsAddress(await effects.runCommand("cat /proc/net/udp"), port);
|
||||
if (hasAddress) {
|
||||
return { status: "passing", message };
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Effects } from "../../types";
|
||||
import { CommandType, Effects } from "../../types";
|
||||
import { CheckResult } from "./CheckResult";
|
||||
import { timeoutPromise } from "./index";
|
||||
|
||||
@@ -9,18 +9,18 @@ import { timeoutPromise } from "./index";
|
||||
* @param param0
|
||||
* @returns
|
||||
*/
|
||||
export const runHealthScript = async (
|
||||
export const runHealthScript = async <A extends string>(
|
||||
effects: Effects,
|
||||
runCommand: Parameters<Effects["runCommand"]>[0],
|
||||
runCommand: CommandType<A>,
|
||||
{
|
||||
timeout = 30000,
|
||||
errorMessage = `Error while running command: ${runCommand}`,
|
||||
message = (res: string) =>
|
||||
`Have ran script ${runCommand} and the result: ${res}`,
|
||||
}
|
||||
} = {}
|
||||
): Promise<CheckResult> => {
|
||||
const res = await Promise.race([
|
||||
effects.runCommand(runCommand),
|
||||
effects.runCommand(runCommand, { timeoutMillis: timeout }),
|
||||
timeoutPromise(timeout),
|
||||
]).catch((e) => {
|
||||
effects.warn(errorMessage);
|
||||
|
||||
Reference in New Issue
Block a user