Giter Site home page Giter Site logo

downtime-worker's Introduction

Downtime Worker

Sends Telegram message when webhook with header X-Auth: [WEB_AUTH] is received.
Uses X-Service-Name, X-Event and X-Tags for more info.

  • X-Service-Name: Friendly name of service. E.g.: 'Server'
  • X-Event: What ever string you like your event to be. E.g.: 'Up', 'Down'
  • X-Tags: Custom tags

The message has the following format:

The check [X-Service-Name] has gone [X-Event]!

Tags: [X-Tags]

Healthchecks

Intended to be used with healthchecks webhooks. Configure like this: webhook config


Running

You can deploy directly:
Deploy to Cloudflare Workers

When running locally you'll need to install wrangler npm i -g @cloudflare/wrangler
And then log in with your cloudflare account: wrangler login


Set secrets (Environment variables)

Run wrangler secret put [name] for each.
WEB_AUTH: Free form token to authorize webhook. Is use a long (>128) base64 key.
TELEGRAM_BOT_KEY: Key from Telegram BothFather. E.g.: 49548951621:a6087sofdzulaisjd_ASDaz789sdgup
TELEGRAM_CHAT_ID: id of your personal chat with the bot.
You can get the key by creating a chat with your bot (Follow BotFather instruction for how-to). And then query https://api.telegram.org/bot[key]/getUpdates


Running Dev Version

Probably need to set CF_ACCOUNT_ID env variable when using more than one account.

Instructions

Windows

setx CF_ACCOUNT_ID <account_id>

You may need to restart you IDE for changes to take effect

Unix

export CF_ACCOUNT_ID=<account_id>

You may need to restart you IDE for changes to take effect

Then run wrangler dev


Publish

Local
wrangler publish

GitHub Actions
Set secrets:
CF_ACCOUNT_ID: Your cloudflare account id
CF_API_TOKEN: Cloudflare api token with at leastworker access rights


Logs

wrangler tail

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.