From f9ffa86c89a43249bb49fc9f041df8d640f691f0 Mon Sep 17 00:00:00 2001 From: Charles Morin Date: Thu, 27 Jul 2023 18:19:12 -0400 Subject: [PATCH] Set exit code to 1 when ping fail --- index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index 490afca..55391fe 100644 --- a/index.ts +++ b/index.ts @@ -9,22 +9,22 @@ import { ping } from "./src/ping.js"; export async function action(options: WebhookRunOptions) { // Block Emitter - const {emitter, moduleHash} = await setup(options, pkg); + const { emitter, moduleHash } = await setup(options, pkg); // Queue - const queue = new PQueue({concurrency: options.concurrency}); + const queue = new PQueue({ concurrency: options.concurrency }); // Ping URL to check if it's valid - if ( !options.disablePing ) { - if (!await ping(options.webhookUrl, options.secretKey) ) { + if (!options.disablePing) { + if (!await ping(options.webhookUrl, options.secretKey)) { logger.error("exiting from invalid PING response"); - process.exit(); + process.exit(1); } } // Stream Blocks emitter.on("anyMessage", async (data, cursor, clock) => { - if ( !clock.timestamp ) return; + if (!clock.timestamp) return; const metadata = { cursor, clock: { @@ -40,7 +40,7 @@ export async function action(options: WebhookRunOptions) { } // Sign body const seconds = Number(clock.timestamp.seconds); - const body = JSON.stringify({...metadata, data}); + const body = JSON.stringify({ ...metadata, data }); const signature = signMessage(seconds, body, options.secretKey); // Queue POST