scheduler

Time-based job runner for Gingee apps (declarative schedules in `app.json`). Server gate: `gingee.json` → `scheduler.enabled` (default false). Multi-node: set scheduler.coordination.driver: "redis" and configure sibling scheduler.redis (same shape as queue.redis / cache.redis) so only one node runs each occurrence (tick locks) or only the elected leader runs jobs (strategy leader). Without coordination, enable the scheduler on at most one node for script/url targets (or use queue targets with redis queue). App config: `app.json` → `schedules` array. Each job needs a unique `name`, a `cron` expression, and a `target` of type script, url, or queue. Permissions: App must be granted scheduler to register any jobs and to require('scheduler'). URL targets also require httpclient; queue targets also require queue. App API: module:scheduler.rebind — refresh this app's CRON registrations from disk app.json without a full platform.reloadApp. Defaults: overlap = skip, misfire = skip, timezone from job or server default (UTC).
Description:
  • Time-based job runner for Gingee apps (declarative schedules in `app.json`). Server gate: `gingee.json` → `scheduler.enabled` (default false). Multi-node: set scheduler.coordination.driver: "redis" and configure sibling scheduler.redis (same shape as queue.redis / cache.redis) so only one node runs each occurrence (tick locks) or only the elected leader runs jobs (strategy leader). Without coordination, enable the scheduler on at most one node for script/url targets (or use queue targets with redis queue). App config: `app.json` → `schedules` array. Each job needs a unique `name`, a `cron` expression, and a `target` of type script, url, or queue. Permissions: App must be granted scheduler to register any jobs and to require('scheduler'). URL targets also require httpclient; queue targets also require queue. App API: module:scheduler.rebind — refresh this app's CRON registrations from disk app.json without a full platform.reloadApp. Defaults: overlap = skip, misfire = skip, timezone from job or server default (UTC).

Members

(inner, constant) appJobs :Map.<string, Map.<string, object>>

Description:
  • appName → Map(jobName → jobRuntime)
appName → Map(jobName → jobRuntime)
Type:
  • Map.<string, Map.<string, object>>

(inner) coordinator :object|null

Type:
  • object | null

(inner) globalConfigRef :object|null

Type:
  • object | null

(inner) serverConfig :Object

Type:
  • Object

(inner) serverLogger :object|null

Type:
  • object | null

Methods

(static) rebind(scheduleNamesopt) → {Promise.<{rebound: Array.<string>}>}

Description:
  • Refresh CRON registrations for the **calling app** from disk app.jsonschedules. Does not reinit db/email or enter maintenance. Omit scheduleNames or pass [] to rebind all jobs; otherwise only the named jobs (unknown names throw). No-op for registration when server scheduler.enabled is false (same as module:scheduler.registerApp), but still refreshes app.config.schedules from disk.
Parameters:
Name Type Attributes Description
scheduleNames Array.<string> <optional>
Job names to rebind; empty/omit = all.
Returns:
Type
Promise.<{rebound: Array.<string>}>

(inner) getAdminStatus() → {object}

Description:
  • Admin/status snapshot for Glade.
Returns:
Type
object

(inner) initServer(config, logger, globalConfig)

Description:
  • Initialize server-level scheduler settings.
Parameters:
Name Type Description
config object | null | undefined from gingee.json → scheduler
logger object
globalConfig object full server config (for box/privileged apps)

(inner) listJobs(optsopt) → {Array.<object>}

Description:
  • List registered jobs (tests / Glade admin UI).
Parameters:
Name Type Attributes Description
opts object <optional>
Properties
Name Type Attributes Description
appName string <optional>
filter by app (substring match if filterPartial)
filterPartial boolean <optional>
Returns:
Type
Array.<object>

(async, inner) registerApp(app)

Description:
  • Register schedules for one app from app.config.schedules. No-op if server scheduler is disabled or app has no schedules.
Parameters:
Name Type Description
app object

(async, inner) reinitApp(appName, app)

Description:
  • Re-read app schedules after reload.
Parameters:
Name Type Description
appName string
app object

(async, inner) runNow(appName, jobName) → {Promise.<object>}

Description:
  • Force-run a registered job (tests / Glade "Run now"). Bypasses multi-node coordination so an operator can always trigger a run.
Parameters:
Name Type Description
appName string
jobName string
Returns:
result status snapshot
Type
Promise.<object>

(inner) shutdown()

Description:
  • Stop all scheduled jobs (server shutdown).

(inner) unregisterApp(appName)

Description:
  • Stop and remove all jobs for an app.
Parameters:
Name Type Description
appName string