Skip to content

Bootstrap Levels

João Morais edited this page Sep 16, 2013 · 10 revisions

Before executing a command Insulin bootstraps the Sugar environment. What it does is something very similar to what is made during a regular page request through the web server, so commands can run in the context of a fully-initialized instance.

The bootstrapping process is characterized by it's different levels, by acting as markers and stating that a specific loading phase has been reached, it allows commands to have an environment context awareness, where each command is only made available depending on the reached level, each command is also able to know that same level and act according to it.

BOOT_INSULIN

Initializes Insulin, no Sugar specific code is available so far. Any code that operates on Insulin and has no dependencies on Sugar directory/installation should bootstrap to this level.

BOOT_SUGAR_ROOT

Sets up Sugar root based on the -p/--path options, or falls back to the current working directory if none supplied. Any code that interacts with the Sugar directory, should bootstrap to this level.

BOOT_SUGAR_CONFIGURATION

Loads Sugar settings from config files.

BOOT_SUGAR_DATABASE

Connects to Sugar database using the credentials loaded in the previous level. Any code that needs to interact with the Sugar database, should bootstrap to this level.

BOOT_SUGAR_FULL

This is the first level where Sugar specific code is made available, which makes this level commonly used by commands that need to interact with Sugar settings, database and code.

BOOT_SUGAR_LOGIN

Logs in to the Sugar instance with a user supplied by the -u/--user options, or falls back to the system user. This level is reached after Sugar has been fully bootstrapped, it's also the level where all commands will try to reach by default, unless another level is specified. Any command that needs access to specific user data should bootstrap to this level.

Clone this wiki locally