Skip to main content
A 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.
On a host that can run Docker, the Connector Docker image with --restart unless-stopped does the same job with less setup.

Create the tunnel

Named tunnels need a recent qa. Run qa upgrade, then check that qa tunnel start --help lists --name.
Sign in with 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:
When the ready summary appears, press 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:
If you installed 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:
Start it, and let it start at boot without a login:
Read the logs with 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:
Load it:
A launchd agent runs while you’re logged in to the Mac and starts again when you log in.

Windows

Task Scheduler starts a PowerShell script that restarts the tunnel whenever it exits. Save this as %USERPROFILE%\qa-tunnel.ps1:
On Windows Server 2016, replace 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:
The account needs the Log on as a batch job right, which administrators have. On a machine that you’re logged in to, run this in PowerShell. The task starts when you log in:
The script writes to %USERPROFILE%\qa-tunnel.log.

Check and stop the tunnel

Check the tunnel from any terminal on the machine:
To stop it for good, remove the service first so it doesn’t restart the tunnel, then revoke it:

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_PROXY from 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.