Engines
An engine is the part of localspace that starts, stops and watches the units of a workspace. This guide tells which engines are available, how to select them for your machine, and how to install the pm2 engine.
Run kinds and engines
Section titled “Run kinds and engines”Each service runs in one of two ways. This is the run kind of the service.
| Run kind | Meaning | Built-in engine |
|---|---|---|
run: container |
The service runs in a container. | docker |
run: process |
The service runs as a process on your machine. | native |
The template can set run: on a service. If it does not, localspace looks at the source of the service. A source with a Dockerfile runs as a container. A different source runs as a process, and localspace uses the command that it finds or the command of the template. A service with an image always runs as a container. The resources of a workspace, such as Postgres and Redis, run as containers.
The two engines work in this way:
dockerdrives thedockerCLI. It uses the Docker context that is active when the workspace is made, such as OrbStack, Docker Desktop or colima. It marks each container with labels, and it stops only containers that have these labels.nativestarts each process in a separate process group and writes its output to a log file. It stops all the processes of the group when the service stops.
localspace has no separate Podman engine. A plugin can add an engine, see write a plugin.
Select the engines
Section titled “Select the engines”Set the engines in the machine settings. The two keys are optional.
engines: container: docker process: nativeThe value is the name of an engine that is installed. The engine must run the run kind of its key. If the name is incorrect, localspace refuses to make a workspace and lists the engines that are installed.
A workspace keeps the engines that were set when you made it. This is the pin. It includes the Docker context. If you change engines: or switch the Docker context, the workspaces that are there continue to use their pinned engine and context. New workspaces use the new settings.
Use a different Docker context
Section titled “Use a different Docker context”- Run
docker context use <context>. For example, useorbstack. - Run
lo new <workspace> --template <template>. The new workspace uses that context.
Workspaces that you made before stay on their context. Their containers are in the engine of that context. Start the engine of that context before you run lo up for them.
Install the pm2 engine
Section titled “Install the pm2 engine”The pm2 plugin adds an engine for run: process. pm2 restarts the processes when they crash, and the processes show in pm2 ls. They continue to run when lo ends.
-
Make sure that
pm2is on yourPATH. -
Run
lo plugin install pm2. This downloads the plugin from the release of your version ofloand checks its checksum. -
Set the engine in the machine settings:
~/.localspace/config.yaml engines:process: pm2 -
Run
lo newfor a workspace. Its process services use pm2.
The pm2 engine runs the process services of a workspace. It does not run containers. Keep container: docker.
The workspaces that you made before keep the native engine.
To see the installed plugins and the items that they add, run lo plugin ls. To remove a plugin, run lo plugin rm <name>.
Check the engines
Section titled “Check the engines”Run lo doctor. The check daemon of the docker engine tells if the Docker daemon answers. The check shell of the native engine tells if /bin/sh is there. lo stats shows the CPU and the memory that each engine uses.