Exports & adapters ​
All exports below are server-side. There is no client API that starts a restart. Configuration and the bridge remain editable through escrow_ignore.
Planning and status ​
local plan, err = exports.np_softrestart:Plan({ 'my_restart_safe_script' })
local status = exports.np_softrestart:Status()
Plan(resources: string[]) returns a plan or nil, error. Names must form a nonempty dense array without duplicates, within MaxResources. A plan has resources (sorted target names), start (dependency order), stop (reverse order) and clientResources (targets not declared server_only 'yes'). It validates started state, explicit opt-in, protected resources, running dependants, cycles, manifest dependency/provide relationships and ExtraDependencies.
Status() returns {phase='idle', lastResult?} or {id, phase, reason, resources, error?}. lastResult is {id, outcome, error?}, with outcome completed, recovered or aborted. A recovered run may include its original error; inspect the result rather than treating idle as proof that the intended deployment succeeded. It exposes no player snapshots or adapter closures. Plan and status are read-only and do not require AllowedInvokers.
Control ​
-- shared/config.lua: Config.AllowedInvokers.my_deployer = true
local id, err = exports.np_softrestart:Begin(
{ 'my_restart_safe_script' },
{ reason = 'Scheduled resource update', hold = true }
)
local ok, err = exports.np_softrestart:Continue(id)
-- Or cancel / attempt recovery:
local ok, err = exports.np_softrestart:Abort(id)
Begin(resources: string[], options?: {reason?: string, hold?: boolean}) returns runId or nil, error. reason is limited to 200 characters. hold=true pauses after stopping for staged file deployment. Only one run can exist; accepting Begin claims it synchronously. The result means the run was accepted, not that maintenance completed. Poll Status() from your deployment controller as appropriate.
Continue(runId: string) succeeds only for the current run in awaiting_deploy. It executes refresh and revalidates current manifests and dependencies before accepting continuation. An invalid deployment stays in awaiting_deploy; fix or revert its files before retrying within the hold budget. Changing the client target set (for example, server_only) is rejected for that run: revert it and schedule a new run. Abort(runId: string) requests cancellation or starts a recovery attempt for a failed run. Both return true on acceptance or false, error for a rejected request; an unauthorized export invocation returns nil, 'invoking resource not permitted'. Success is not proof that asynchronous recovery completed. Verify status.
Begin, Continue and Abort require an actual invoking resource explicitly enabled in Config.AllowedInvokers. Player commands are separately ACE-gated. The optional np_admin actions require both their permission node and the matching management ACE.
Register an adapter ​
local ok, err = exports.np_softrestart:RegisterAdapter({
name = 'my_bridge.jobs',
resources = { 'my_restart_safe_script' },
prepare = function(context)
-- Finish/cancel transactions through documented APIs.
-- Store only the state you own in this bridge's closure.
return true
end,
resume = function(context, success)
-- Restore your integration and release its own lock.
-- success=false means cancellation / recovery.
return true
end,
})
RegisterAdapter(def) returns true or false, error. The coordinator binds owner to the actual invoking resource; a caller cannot choose another owner. Registration is unavailable while maintenance is active. Names use resource-name-safe letters, digits, underscores, hyphens and dots (maximum 100 characters). An existing adapter name can only be replaced by its owner. Ownership ends when that resource stops; re-register when the bridge or coordinator starts.
resources: string[] selects which target names activate the adapter. An empty array runs it for every maintenance window. Optional prepare(context) and resume(context, success) callbacks must return true when present, or false, error on failure. They execute only on the server. Keep the adapter owner running: a plan targeting any registered adapter's owner is rejected.
The context contains {id: string, reason: string, resources: string[], players: number[]}. Treat it as coordinator-owned; do not mutate its fields. players is the initial roster, so check the player is still connected before acting on a source. Optional bridges may add their own namespaced state. Keep private snapshots in your own bridge closure and validate session identity if you use source IDs asynchronously.
Adapters prepare in name order and resume in reverse order. An adapter is included for cleanup even when preparation partially fails. Resume callbacks should be idempotent and safe to retry after a failed recovery. Every prepared adapter is offered resume even if another resume fails. A callback has PrepareTimeoutMs; a timed-out callback cannot be forcibly cancelled and keeps maintenance locked until it completes and explicit recovery is requested. Never leave uncontrolled background work running after reporting readiness.
Events and client boundary ​
The local server event np_softrestart:phase(id: string, phase: string) announces transitions. It is a notification, not a veto or a state-saving API. Use an adapter when completion must be awaited.
The coordinator owns np_softrestart:state (server-to-client), np_softrestart:ack and np_softrestart:sync (client-to-server). These are internal readiness/presentation messages, not extension APIs. Clients cannot provide authoritative positions, inventory, rewards or restart permission. A lifecycle acknowledgement establishes observed stop/start, not arbitrary script readiness or asset safety. Resource-specific readiness must be handled through the script's supported contract.