qa tunnel runs as long as its process does. To keep one
online across crashes and reboots, give it a name and let your operating
system’s service manager restart it. A named tunnel keeps its ID, so Mo sessions
that use it keep working.
Create the tunnel
Named tunnels need a recent
qa. Run qa upgrade, then check that qa tunnel start --help lists --name.qa login, then create the tunnel once in
a terminal. Replace localhost:3000 with your app’s address and checkout-dev
with a name for the tunnel:
Ctrl+C. The tunnel goes offline but
isn’t revoked, and qa tunnel list shows it as offline. The service below
resumes it with the same command. Resuming a named tunnel doesn’t call the
Momentic API, so the service doesn’t need an API key.
Linux
Run the tunnel as a systemd user service. Save this as~/.config/systemd/user/qa-tunnel.service, with the absolute path that
command -v qa prints:
qa with npm, it runs on Node.js, which the service can’t find
through your shell’s PATH. Add a line under [Service] with the directory
that command -v node prints:
journalctl --user -u qa-tunnel.service.
macOS
Run the tunnel as a launchd agent. Save this as~/Library/LaunchAgents/ai.momentic.qa-tunnel.plist, with the absolute path
that command -v qa prints:
Windows
Task Scheduler starts a PowerShell script that restarts the tunnel whenever it exits. Save this as%USERPROFILE%\qa-tunnel.ps1:
qa.cmd and qa with
npx.cmd --yes @momentic/qa-node throughout this page, including the check and
stop commands. See Windows Server 2016.
Then register the script with Task Scheduler. Pick the block for how the machine
is used.
On a machine that runs without anyone logged in, such as a server, run this in
an elevated PowerShell. The task starts at boot:
%USERPROFILE%\qa-tunnel.log.
Check and stop the tunnel
Check the tunnel from any terminal on the machine:Notes
- Each user account runs one tunnel at a time. To expose several apps, pass every address to the one tunnel.
- To change a tunnel’s addresses, stop it and create a new one. A name can’t be
reused after
qa tunnel stop, so pick a new one. - The service doesn’t inherit proxy variables such as
HTTPS_PROXYfrom your shell. If the machine needs a proxy to reach Momentic, set it in the service definition. - The machine needs the tunnel network access whenever the service runs.