GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — SpaceWorks-Inventory/deploy/cloudflare-cron at main · SpaceWorks-Labs/SpaceWorks-Inventory

Expand file tree

/

cloudflare-cron

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

cloudflare-cron

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
src
src
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
wrangler.toml
wrangler.toml
 
 

README.md

Outline

Space Works Inventory cron Worker

A Cloudflare Worker with a Cron Trigger (* * * * *). Every minute it:

  1. GET {APP_URL}/api/health wakes the app if a free instance is asleep (cold starts take about 30–60 s; the Worker waits up to 90 s).
  2. POST {APP_URL}/api/internal/outbox?run=inline with Authorization: Bearer {CRON_SECRET} makes the web instance do the background work itself, once: deliver queued email and webhooks, send loan reminders and overdue escalations, open scheduled cycle counts, reconcile pending payments and run the retention purge.

That is all a free web-only deployment needs. When a worker and beat run elsewhere, set the Worker variable INLINE=false: it then only queues work (/api/internal/outbox and /api/internal/jobs) for that worker. Both paths are safe to run at once: outbox rows, reminders and jobs are claimed atomically. The VPS stack ships its own worker and beat and does not need this Worker.

This folder is a separate package: it is excluded from the app's TypeScript, ESLint, Vitest and Docker build, and its only dependency is wrangler. The root dependency audit does not cover this lockfile. The quality workflow installs and audits it separately, then bundles it with npm run check in a Git-visible source copy with an empty user profile and metrics disabled. That check has no Cloudflare credentials and does not deploy the Worker.

Deploy

cd deploy/cloudflare-cron
npm ci
npx wrangler login
npx wrangler secret put APP_URL       # e.g. https://inventory.example.org (https, no trailing slash)
npx wrangler secret put CRON_SECRET   # the same value as the app's CRON_SECRET
npx wrangler deploy

wrangler.toml sets workers_dev = false, so the Worker has no public URL. It only runs on its schedule.

Operate

  • npx wrangler tail streams logs. Expect health 200 and outbox 200 every minute (plus jobs 204 with INLINE=false). Only status codes are logged.
  • 404 from outbox or jobs: CRON_SECRET differs from the app's value.
  • outbox 500: the app could not run the outbox (database or SMTP). Check the app logs and Admin → Outbox.
  • After rotating the app's CRON_SECRET, run wrangler secret put CRON_SECRET again.
  • npm run check bundles the Worker without deploying it.

Cloudflare's free Workers plan allows 100,000 requests a day; this Worker uses about 1,440 scheduled runs a day.

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.