Fixed ports
Each workspace gets host ports that localspace selects, so the workspaces do not collide. Some applications cannot use these ports. An application can have a port in its code, or an OAuth provider can have a callback address such as http://localhost:3000. This guide tells how to give the ports of the template to one workspace.
How lo checkout works
Section titled “How lo checkout works”The ports of the template are the ports that the units use when only one copy runs. For example, a service has port: 3000, and a Postgres instance has its default port 5432. A resource has such a port only when its isolation is instance.
lo checkout <workspace> starts a forwarder for each of these ports. The forwarder listens on 127.0.0.1 at the port of the template. It sends the traffic to the unit of the workspace. A browser that opens http://localhost:3000 then reaches the service of that workspace.
Only one workspace has the ports at a time. When you check out a second workspace, it takes the ports from the first. The first workspace continues to run. Its units are not reachable at the ports of the template. You can reach them at their host ports and their public URLs.
Check out a workspace
Section titled “Check out a workspace”Before you start, make sure that the workspace runs. lo checkout refuses a workspace when a unit that has a port of the template does not run.
-
Run
lo up <workspace>. -
Run
lo checkout <workspace>. -
Read the plan that
lo checkoutprints on the standard error. Each line has this form:127.0.0.1:3000 → shop-a/storefront, taken from shop-b/storefront -
Type
yand press Enter to accept the plan.
The command prints each port that it forwards. Use --yes to skip the question, for example in a script.
The plan also shows these items:
taken fromshows a port that a different workspace has now.releasedshows a port that is forwarded now and that the new checkout does not use. It stops reaching its workspace.skippedshows a port that more than one unit of the workspace uses. A forwarder can reach only one unit, so localspace does not forward the port. Give the units different ports in the template.
Ports that other programs use
Section titled “Ports that other programs use”If a program that localspace did not start listens on a port of the template, lo checkout refuses and changes nothing. It gives the name and the process ID of the program, for example postgres (pid 812). Stop that program, then run lo checkout again.
Fixed host names
Section titled “Fixed host names”An SSO provider can accept only one callback address, for example https://sso.acme.com. Each workspace has a separate URL, so the address cannot be the URL of a workspace. Give the service an alias in the template:
domains: [acme.com]services: web: port: 3000 expose: true aliases: [sso.acme.com]An alias is a fixed host name in one of the domains of the template. One workspace answers it at a time. Each workspace keeps its normal URL, for example https://web.shop-a.lo.
- Run
lo upfor each workspace. - Run
lo checkout <workspace>. The plan shows each alias, for examplesso.acme.com → shop-a/web. - Type
yand press Enter.
https://sso.acme.com then reaches the service web of shop-a. Run lo checkout shop-b to move it. The workspace shop-a keeps running at its normal URL. The plan shows taken from for an alias that a different workspace has now.
Use lo checkout <workspace> --hosts to move only the aliases. The command does not forward the ports, and the unit does not have to run. An alias answers when the service of its workspace runs. If no workspace holds the alias, the proxy has no route for it.
Aliases work only with the proxy in domain mode. The DNS server of localspace answers the names, because they are in the domains of the template. See aliases.
Release the ports
Section titled “Release the ports”Run lo checkout --release to stop all the forwarders and to free all the aliases. The command works for the workspace that has them now. You do not give a workspace name. It shows the items that stop reaching their workspace and waits for your answer. Use --yes to skip the question.
lo rm of the workspace that has the ports also removes its forwarders and frees its aliases. lo down does not remove them.
Related
Section titled “Related”- Public URLs give each workspace a separate address without a checkout.
lo checkout