Skip to content

Router Lifecycle

Startup Process

Load router configuration

The SwiftletManager loads the router configuration from the routerconfig.xml file, parses the startorder attribute, and initializes internal data structures.

Start static kernel Swiftlets

The sys$trace Swiftlet is always started first, followed by sys$log. These are required for tracing and logging during further startup.

Start kernel Swiftlets in startorder

Kernel Swiftlets listed in the startorder attribute of the router tag in routerconfig.xml are instantiated and started in order. Each is loaded, its configuration is applied, and its startup method is called.

Start extension Swiftlet deployer

After all kernel Swiftlets are started, the extension Swiftlet deployer (sys$deploy) is started (unless in HA mode), enabling runtime deployment of extension Swiftlets.

Initialize keep-alive thread and finalize startup

A keep-alive thread is started to keep the process running, and the system logs that the router is ready.

Shutdown Process

Shutdown is performed in reverse order of startup. First, all extension Swiftlets are stopped and unloaded. Then, kernel Swiftlets are shut down in the reverse of their start order, with sys$trace always stopped last. Each Swiftlet's shutdown method is called, and its state is set to inactive. Before shutdown, the configuration is saved if it is marked as dirty. The shutdown process can be triggered cleanly (e.g., via CLI or management command) or forcibly (e.g., process kill). In a clean shutdown, the shutdown hook ensures all resources are released and the configuration is saved. In a forced kill, configuration and state may not be preserved.

Extension Swiftlets

Extension Swiftlets are managed by the Deploy Swiftlet (sys$deploy). They can be deployed (loaded) or undeployed (unloaded) at runtime without restarting the router. When a bundle is added, CLI commands defined in the bundle are executed, the Swiftlet is loaded and started, and the configuration is saved. When a bundle is removed, the Swiftlet is shut down and unloaded, cleanup CLI commands are executed, and the configuration is saved if necessary. Each extension Swiftlet runs in its own class loader, isolated from kernel Swiftlets.

Configuration File

routerconfig.xml is the main configuration file for the router. It contains a router XML element with attributes such as name, kernelpath, release, and crucially, startorder. The startorder attribute lists the kernel Swiftlets to be started, in order, separated by spaces, commas, or colons. The configuration file also stores other settings and the configuration for each Swiftlet. During startup, the file is parsed, and the listed Swiftlets are started in order. On shutdown or configuration changes, the configuration is saved back to routerconfig.xml, with a backup created before each save.