mirror of
https://github.com/jason5ng32/MyIP.git
synced 2026-11-04 08:55:47 +00:00
MaxMind and CAIDA each had their own updater with its own lock, state file, publish step, boot download and timer. One engine (common/dataset-updater.js) now owns all of that, and each dataset is a row in common/datasets.js that holds only its own logic: find the newest remote version, fetch or distill it, validate, reload. - Locks: proper-lockfile, a heartbeat lock shared by every process, so a crashed holder's lock goes stale on its own; a booting server waits for a live holder and loads what it published. - State: one file per dataset, written with write-file-atomic; the old .maxmind-update-state.json / .caida-update-state.json are read once, so an upgrade doesn't re-download. - Schedule: croner at a fixed time (DATASET_UPDATE_CRON, default 04:30 local) instead of 24 h from process start, plus a catch-up run at boot for a check a downtime skipped. DATASET_AUTO_UPDATE (default on) replaces MAXMIND_AUTO_UPDATE / CAIDA_AUTO_UPDATE, which still apply when it is unset. - Reload: the engine watches every dataset's files, so a publish by another process or a hand-placed .mmdb is picked up; MaxMind's own watcher goes. MaxMind's City and ASN editions now publish together under one version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
1.1 KiB
JavaScript
22 lines
1.1 KiB
JavaScript
// Sentry Cron check-in wrapper for the backend's periodic jobs (the dataset
|
|
// updater, service-status). Same gating as sentry-instrument.js: without
|
|
// SENTRY_DSN_BACKEND this is a pure passthrough and @sentry/node is never
|
|
// loaded, so job modules can call it unconditionally.
|
|
//
|
|
// The monitor is upserted from the monitorConfig on first check-in — nothing
|
|
// to pre-create in the Sentry UI. A rejected job promise reports an "error"
|
|
// check-in and rethrows, so callers keep their own .catch logging.
|
|
|
|
let sentryWithMonitor = null;
|
|
// Check-ins are production-only: a dev machine's monitor starts reporting
|
|
// "missed" the moment the dev server stops, paging about a closed laptop.
|
|
// Everything else about Sentry still works normally in development.
|
|
if (process.env.SENTRY_DSN_BACKEND && process.env.SENTRY_ENVIRONMENT !== 'development') {
|
|
({ withMonitor: sentryWithMonitor } = await import('@sentry/node'));
|
|
}
|
|
|
|
export const withCronMonitor = (slug, fn, monitorConfig) => {
|
|
if (!sentryWithMonitor) return fn();
|
|
return sentryWithMonitor(slug, fn, monitorConfig);
|
|
};
|