Work with several boxes
When two boxes, here fork-a and fork-b, run the same lanes, as copies made from one image do, your machine stays connected to both and one of them serves each lane at a time.
Give each box its own ports
Section titled “Give each box its own ports”Two boxes know nothing of each other’s ports, so split the box’s part of the range between them, keeping your machine’s part from Prepare a box. Copies of one image start with the same ports.range, so set it on each copy before its first devlanes command.
# ~/.devlanes/config.yaml on fork-aports: range: 28000-30399portsPort range that every lane of every project takes its block of ports from, so lanes never collide. Defaults to 20000-32767.
ports.rangePorts devlanes may hand out, written start-end (both included, start above 0); defaults to 20000-32767, below Linux's usual ephemeral range so the OS does not pick them for outgoing connections. Each lane of each project gets its own block of consecutive ports from it, so a smaller range fits fewer lanes.
# ~/.devlanes/config.yaml on fork-bports: range: 30400-32767portsPort range that every lane of every project takes its block of ports from, so lanes never collide. Defaults to 20000-32767.
ports.rangePorts devlanes may hand out, written start-end (both included, start above 0); defaults to 20000-32767, below Linux's usual ephemeral range so the OS does not pick them for outgoing connections. Each lane of each project gets its own block of consecutive ports from it, so a smaller range fits fewer lanes.
Then connect to each box under its own name, as Connect to a box describes.
Know which box serves a lane
Section titled “Know which box serves a lane”When lanes share hostnames, as lane 0 of myapp does on both boxes, your machine mirrors one of them, in this order:
- a lane on your machine that runs
- the box lane you chose
- a lane on your machine that is stopped
- the lane of the box that connected first
devlanes remote ls lists the lanes it skipped, each with the command that switches to it.
$ devlanes remote lsSwitch to another box
Section titled “Switch to another box”Choose the box that serves the lane.
$ devlanes remote use fork-b myapp@0The switch keeps the lane’s hostnames, but not its port numbers, since each box gave the lane ports from its own range. A browser follows the switch; a program that connects to a port number, such as a database client, needs the new box’s port, which devlanes remote ls shows. The choice lasts until another one replaces it or you disconnect the box.
If a lane on your machine runs
Section titled “If a lane on your machine runs”A running local lane keeps its hostnames, so the choice is refused. Stop the lane, then choose the box again.
$ devlanes stop$ devlanes remote use fork-b myapp@0