STAXIS

staxis js platform -> gitlab project
staxis on gitlab gitlab project 🏷️ V-0.X-Beta
We’re actively updating this manual. Content and layout may change as we refine it.

graceful

Official sources are open to Staxis GitLab group members: how to join and view the code.
Repository: graceful development
Versions: tags and releases


Description

graceful requests the ordered shutdown of selected stack components. It walks a configured list of layers, asks each one to detach, and collects the results. Its published assets contain a status message and a close() function.

An authorized operational layer can call it from a controlled shutdown endpoint or a scheduled restart flow. graceful coordinates the detach sequence; it does not itself exit or restart the Node.js process, register a shutdown endpoint, or install signal handlers.


Read before flight

  • We suggest listing dependent layers first and their underlying services last, with each target included once. Every target must be loaded, detachable, and authorize graceful.

  • We suggest choosing the failure policy before using close(). The default stops at the first failed detach; enabling gracefulNonStop attempts the remaining targets. Completed detaches are not rolled back.

  • We suggest checking the report before continuing your shutdown flow. Each target owns its cleanup: a returned detach object does not by itself prove that every external resource or background task has stopped.


Files Map

File Purpose
manifest.json Declares the graceful label, typology, and permitted callers
configs.js Defines the shutdown order and failure policy
main.js Requests supervised detaches and builds the report
.fomap File map used by the Manager installation flow
README.md Original setup and usage reference

Requirements and Installation

graceful requires the Staxis Core and loaded target layers that support detach. It has no additional npm dependency. Install it through the Manager:

                manager -> install -> graceful
            

Place graceful before the operational layers that consume it and prepare its Vault material through First setup. Both its manifest.label and manifest.typology are graceful; its typology key is KEY:GRACEFUL. healthz is not an intrinsic dependency of this mechanism.


Configuration

Both options belong to config.engineopt. Merge them into config.js, preserving the project's other engine options. The supplied defaults are:

                // config.js -> config (merge into the exported object)
                engineopt: {
                    gracelist: [],
                    gracefulNonStop: false
                }
            

config.engineopt.gracelist accepts an ordered array of target pack labels or layer typologies. An empty array leaves close() with nothing to detach. Configure the most dependent components first and the lowest-level runtime pieces last. For example, replacing these illustrative names with your actual targets:

                // config.js -> config (merge into the exported object)
                engineopt: {
                    gracelist: ['someDependentLayer', 'someBaseLayer'],
                    gracefulNonStop: false
                }
            

config.engineopt.gracefulNonStop defaults to false: the first failed detach stops the sequence and returns the report collected so far. Set it to true only when you explicitly want the remaining targets attempted after a failure. Failures still appear in the report and make its final status false.


Permissions

There are two authorization directions. First, the calling pack's manifest.label must appear in graceful's manifest.permits. The supplied manifest already permits graceful and sysrestart. To authorize another consumer, preserve those entries and add its label:

                // graceful/manifest.json: permits field
                "permits": ["graceful", "sysrestart", "someOtherLayer"]
            

Second, every target pack in gracelist must include graceful in its own manifest.permits. Add the entry alongside the target's existing permitted callers:

                // Each target pack's manifest.json: add this label to permits
                "graceful"
            

During close(), graceful resolves each configured label or typology, requests access to the target pack label through Vault, and retrieves its protected API and original bundle separately. It then submits the caller identity, target identity, and request reason to the Core's supervised detach flow. Listing a target in gracelist does not grant access to it.


How to Use

Inside an authorized calling layer, use its engine and layers equipment. In the example, someOtherLayer is the caller's manifest.label, not its runtime slot. The Vault target is graceful's pack label; layers.require selects its graceful typology:

                const tokenAccess = engine.vault.requireAccess(
                    'someOtherLayer', // Requesting pack's manifest.label
                    'graceful'        // Provider pack's manifest.label
                )

                if (typeof tokenAccess !== 'string' || /^error:/i.test(tokenAccess)) {
                    throw new Error('Access to graceful was denied')
                }

                const instance = layers.require(
                    'graceful', // Provider's manifest.typology: its runtime slot
                    tokenAccess,
                    false
                )

                const graceful = instance?.assets

                if (!graceful || typeof graceful.close !== 'function') {
                    throw new Error('graceful is unavailable')
                }

                const result = await graceful.close()

                if (typeof result === 'string') {
                    throw new Error(result)
                }

                if (result.status === false) {
                    // Inspect result.report before deciding how to continue.
                }

                // result.status === 'nothing to do...' means gracelist is empty.
            

Shutdown Report

For an attempted sequence, close() returns an object with status and report. The report keys are the configured target names; each value is the object returned by that target's detach or a diagnostic string describing its failure.

Result Meaning
status: true All recorded detach requests returned an object
status: false A target request failed; inspect report and the configured continuation policy
{ status: 'nothing to do...', report: 'not active' } The configured list is empty
A diagnostic string The sequence could not initialize, for example because graceful could not obtain its own Vault identity

Calling close() is separate from deactivating graceful itself. Its own detach only replaces the published assets with an inactive status and close: 'not active'; it does not run the configured shutdown sequence.


Documentation

This page is the HTML adaptation of the pack's README.md, with explicit configuration parents, caller and target permissions, and report handling. Complete Staxis onboarding to request access to the official GitLab sources.