Skip to content

Commit

Permalink
Set exit code to 1 when ping fail
Browse files Browse the repository at this point in the history
  • Loading branch information
chamorin committed Jul 27, 2023
1 parent 1329494 commit f9ffa86
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand Down

0 comments on commit f9ffa86

Please sign in to comment.