sysrestart
Official sources are open to Staxis GitLab group members:
how to join and view the code.
Repository: sysrestart development
Versions: tags
and releases
Description
sysrestart is an autorun layer that registers a recurring maintenance restart through the scheduler slot provided by chronjobs. It does not implement another scheduler. Its published assets report the configured job and schedule metadata.
The pack label is sysrestart; its runtime typology is systemRestart. With autorun enabled, attaching the layer registers the job automatically. You configure when and how the instance restarts rather than wiring the scheduled function from another layer.
Read before flight
-
We suggest choosing the schedule and timezone before enabling the pack on a live instance. The supplied schedule runs at midnight every Sunday, not every night.
-
We suggest reviewing config.engineopt.guard.allowOpaqueExecution, enabled by the pack for process creation, and the chronjobs import/filesystem rules used to load the restart function.
-
We suggest configuring and testing graceful's target list when using the default graceful strategy. An empty list returns a non-failing report and therefore does not prevent the restart.
-
We suggest checking the restart policy of your host, container, or process manager. sysrestart launches its own replacement through node project start; coordinate that ownership with any external automatic restart mechanism.
Files Map
| File | Purpose |
|---|---|
| manifest.json | Declares the sysrestart label, systemRestart typology, scheduler dependency, and autorun behavior |
| configs.js | Supplies the restart strategy, cron expression, and execution capability |
| main.js | Registers the restart job and stops that named schedule on detach |
| systemNightlyRestart.js | Runs the selected restart strategy when the scheduled job fires |
| restartController.js | Waits for the requesting process to exit, then starts its replacement |
| .fomap | File map used by the Manager installation flow |
| README.md | Original configuration and usage reference |
Requirements and Installation
Install through the Manager:
manager -> install -> sysrestart
chronjobs must be active before sysrestart, providing the scheduler slot and permission for the sysrestart pack label. The supplied chronjobs manifest already includes that caller. The default graceful strategy also requires an active graceful layer, whose supplied manifest likewise permits sysrestart. Place both providers before sysrestart in the stack.
Prepare the normal Vault material through First setup. The typology key for this pack is KEY:SYSTEMRESTART. Its scheduler dependency is declared as "require": ["scheduler"] in the manifest. Keep its supplied "autorun": true setting for automatic registration; no additional npm restart library is required.
Configuration
The restart options belong to config.engineopt. Merge the supplied defaults into the final config.js object, preserving other engine options and Guardian settings:
// config.js -> config (merge into the exported object)
engineopt: {
systemRestartType: 'graceful',
systemRestartTime: '0 0 0 * * 0',
guard: {
allowOpaqueExecution: true
}
}
config.engineopt.systemRestartTime uses the six-field cron format: second, minute, hour, day, month, dayOfWeek. The default means Sunday at 00:00:00 in config.engineopt.syszone. Set that timezone explicitly in the same engineopt branch if needed; sysrestart falls back to GMT when it is absent. chronjobs validates both the expression and the effective timezone.
To disable the recurring restart deliberately, use the boolean false:
// config.js -> config (merge into the exported object)
engineopt: {
systemRestartTime: false
}
This is a supported configuration, not an initialization failure. Apply the change through your normal configuration and layer startup flow; editing the value alone does not cancel an already registered schedule.
Restart Strategies
| config.engineopt.systemRestartType | Behavior |
|---|---|
| graceful | Calls graceful.close() before preparing the replacement. A missing facade, a non-object report, or status: false prevents the restart. |
| soft | Prepares the replacement and exits the requesting instance without the layer detach sequence. |
| hard | Currently follows the same process flow as soft, also skipping the layer detach sequence. |
All three strategies act on the requesting Staxis instance. hard does not scan or kill other Node.js processes. For graceful, configure config.engineopt.gracelist and the target permissions as explained in the graceful manual. A failed shutdown can already have detached earlier targets, so inspect its logs before retrying.
How to Use
Leave the pack in autorun mode and configure the final system options above, or the pack's configs.js before merging them. At attach time, sysrestart obtains access with the caller label sysrestart and provider label chronjobs, then requests the scheduler runtime slot. It registers the following internal-function job conceptually, as in the README:
scheduler.new(
'system-nightly-restart',
config.engineopt.systemRestartTime,
config.engineopt.syszone || 'GMT',
'internal-function',
'./' + config.engineopt.folders.lrpcks + '/sysrestart/systemNightlyRestart.js',
{ engine, config, logs, layers }
)
This registration is already performed by the pack; do not register a second job manually. The function receives the runtime equipment needed for the restart, not just an arbitrary reason string. The script path follows config.engineopt.folders.lrpcks, normally system-lrpcks. The explicit name system-nightly-restart is also the identity used to locate and stop this schedule when sysrestart is detached.
Restart Flow
After any required graceful sequence, the job starts a detached Node.js controller and waits for its spawn event. If process creation fails at that point, the requesting instance does not execute the subsequent exit. Once the controller has spawned, the current process exits with code 0.
The controller waits for that exact PID to disappear, checking every 100 milliseconds for up to 30 seconds. It then launches node project start from engine.baseroot with the same Node executable and inherited environment, and exits after the replacement spawns. It never searches for processes by name. Spawn confirmation is not an application-readiness check: verify startup and service availability through your usual operational monitoring.
Published Status and Detach
The active assets report restarter, resetTime, chronjobTime, and chronjobData. chronjobData includes the job name, target, execution type, timezone, cron expression under taskDate, and whether the job exposes an event subscription method. These fields describe the registered schedule; the facade does not expose a restartNow() command.
When the schedule is disabled, the assets contain restarter: 'not in use', resetTime: false, and chronjobTime: false. Detach stops only system-nightly-restart through the scheduler and publishes the same inactive state. Other scheduled jobs remain under their owners' control.
Documentation
This page is the HTML adaptation of the pack's README.md, with practical clarifications checked against the implementation. Complete Staxis onboarding to request GitLab access to the official sources.