Skip to content

Router Lifecycle

Startup Process

Load Configuration

The SwiftletManager loads the router configuration from the routerconfig.xml file, including attributes such as startorder, kernelpath, and router name.

Parse Start Order

The startorder attribute from the router element in routerconfig.xml is parsed to determine the boot sequence of Kernel Swiftlets.

Start sys$trace

The sys$trace Swiftlet (Trace Swiftlet) is always started first to enable tracing for all subsequent startup steps.

Start sys$log

The sys$log Swiftlet (Central Logging Facility) is started next to ensure logging is available for all further components.

Start Kernel Swiftlets in startorder

Each Kernel Swiftlet listed in the startorder attribute is instantiated and started in order. The startup method is called for each, passing its configuration.

Start Extension Swiftlet Deployer

After all Kernel Swiftlets are started, the Extension Swiftlet deployer is started. This enables runtime deployment and undeployment of Extension Swiftlets.

Initialize Keep-Alive Thread

A keep-alive thread is started to keep the router process alive.

Save Configuration if Dirty

If the configuration was changed during startup, it is saved to routerconfig.xml.

Shutdown Process

During shutdown, the SwiftletManager first saves the configuration if it is dirty. It then stops all Extension Swiftlets, followed by Kernel Swiftlets in the reverse order of startup (i.e., last started is first stopped). For each Swiftlet, the shutdown method is called. The shutdown process ensures that resources are released in dependency order. The shutdown can be triggered cleanly (via CLI or management command), or forcibly (kill), but a clean shutdown ensures configuration is saved and resources are properly released.

Extension Swiftlets

Extension Swiftlets can be deployed and undeployed at runtime via the Deploy Swiftlet (sys$deploy). When a bundle is added, loadExtensionSwiftlet is called, which loads, configures, and starts the Swiftlet using its own class loader. When a bundle is removed, unloadExtensionSwiftlet is called, which shuts down and removes the Swiftlet. CLI commands defined in the bundle's configuration can be executed before install and after remove. Extension Swiftlets are not part of the static boot order and can be managed dynamically during router operation.

Configuration File

routerconfig.xml is the main configuration file for the router. The root router element contains attributes such as name, kernelpath, startorder, and optional attributes like use-smart-tree and memory-collect-interval. The startorder attribute is a comma/space/colon-separated list of Kernel Swiftlet names that defines the startup order. Each Swiftlet's configuration is stored as a child element. The file is loaded at startup and saved during shutdown or when configuration changes. Backups are created when saving.