-
Notifications
You must be signed in to change notification settings - Fork 2k
src backend Kernel
The Puter Kernel is the core runtime component of the Puter system. It provides the foundational infrastructure for:
- Initializing the runtime environment
- Managing internal and external modules (extensions)
- Setting up and booting core services
- Configuring logging and debugging utilities
- Integrating with third-party modules and performing dependency installs at runtime
This kernel is responsible for orchestrating the startup sequence and ensuring that all necessary services, modules, and environmental configurations are properly loaded before the application enters its operational state.
-
Modular Architecture:
The Kernel supports both internal and external modules:-
Internal Modules: Provided to Kernel by an initializing script, such
as
tools/run-selfhosted.js
, via theadd_module()
method. -
External Modules: Discovered in configured module directories and installed
dynamically. This includes resolving and executing
package.json
entries and runningnpm install
as needed.
-
Internal Modules: Provided to Kernel by an initializing script, such
as
-
Service Container & Registry:
The Kernel initializes a service container that manages a wide range of services. Services can:- Register modules
- Initialize dependencies
- Emit lifecycle events (
boot.consolidation
,boot.activation
,boot.ready
) to orchestrate a stable and consistent environment.
-
Runtime Environment Setup:
The Kernel sets up aRuntimeEnvironment
to determine configuration paths and environment parameters. It also provides global helpers likekv
for key-value storage andcl
for simplified console logging. -
Logging and Debugging:
Uses a temporaryBootLogger
for the initialization phase until LogService is initialized, at which point it will replace the boot logger. Debugging features (ll
,xtra_log
) are enabled in development environments for convenience.
-
Constructor:
When a Kernel instance is created, it sets up basic parameters, initializes an empty module list, and preparesuseapi()
integration. -
Booting:
Theboot()
method:- Parses CLI arguments using
yargs
. - Calls
_runtime_init()
to set up theRuntimeEnvironment
and boot logger. - Initializes global debugging/logging utilities.
- Sets up the service container (usually called
services
c instance of Container). - Invokes module installation and service bootstrapping processes.
- Parses CLI arguments using
-
Module Installation:
Internal modules are registered and installed first.
External modules are discovered, packaged, installed, and their code is executed.
External modules are given a special context with access touseapi()
, a dynamic import mechanism for Puter modules and extensions. -
Service Bootstrapping:
After modules and extensions are installed, services are initialized and activated. For more information about how this works, see boot-sequence.md.
This wiki is generated from the repository. Do not edit files the wiki.
You are reading documentation for Puter, an open-source high-level operating system.
Getting started with Puter on localhost is as simple as:
git clone https://github.com/HeyPuter/puter.git
npm install
npm run start