pinggy 0.6.11 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +28 -18
- package/CLAUDE.md +5 -4
- package/README.md +20 -4
- package/dist/{chunk-RYO5T2JT.js → chunk-2IPBK3RG.js} +139 -115
- package/dist/{chunk-3IPMFCEF.js → chunk-QUVQ7ODD.js} +1 -0
- package/dist/{chunk-W47AYOH2.js → chunk-ZSED6OIR.js} +276 -33
- package/dist/{configStore-6LCHFPQX.js → configStore-VDPOPFLJ.js} +1 -1
- package/dist/{daemonChild-GGG34AOT.js → daemonChild-5HZFQLQR.js} +3 -3
- package/dist/index.cjs +416 -150
- package/dist/index.js +4 -4
- package/dist/{main-FCIOVX5I.js → main-M4BTDE2A.js} +3 -3
- package/dist/{updateChild-RNCLN24C.js → updateChild-CEVYCBED.js} +1 -1
- package/package.json +2 -1
- package/scripts/install/install.ps1 +9 -8
- package/scripts/install/install.sh +8 -7
package/ARCHITECTURE.md
CHANGED
|
@@ -11,7 +11,7 @@ The `pinggy` binary has three execution modes, dispatched in `src/main.ts`:
|
|
|
11
11
|
| Mode | Trigger | Entry | Purpose |
|
|
12
12
|
| -------------------- | -------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
13
13
|
| Daemon child | `--_daemon-child` flag | `runDaemonChild()` in `src/daemon/daemonChild.ts` | Long-running background process. Owns the `TunnelManager` and the SDK. |
|
|
14
|
-
| Subcommand | First arg in `SUBCOMMANDS` set | `handleSubcommand()` in `src/cli/subcommands.ts` | Short-lived CLI invocation:`config`, `start`, `stop`, `ps`, `attach`, `daemon`, `logs`, `log`, `restart`, `device`,
|
|
14
|
+
| Subcommand | First arg in `SUBCOMMANDS` set | `handleSubcommand()` in `src/cli/subcommands.ts` | Short-lived CLI invocation:`config`, `start`, `stop`, `ps`, `attach`, `daemon`, `logs`, `log`, `restart`, `device`, `devices`, which prints the new spelling, `update`, and `autostart`. |
|
|
15
15
|
| Update child | `--_update-child` flag | `runUpdateChild()` in `src/update/updateChild.ts` | Short-lived detached process. Checks for a release, downloads it, swaps it in. See section 20. |
|
|
16
16
|
| Legacy single-tunnel | No subcommand, has flags | `buildAndStartTunnel()` in `src/cli/buildAndStartTunnel.ts` | Backwards-compatible single-shot tunnel for flags like `-l 3000` or `-R0:...`. |
|
|
17
17
|
|
|
@@ -290,7 +290,7 @@ A restore can be cut short by the next crash, and a host that restarts the daemo
|
|
|
290
290
|
|
|
291
291
|
Auto-start tunnels are independent of crash recovery. They come from saved configs marked `autoStart: true` (`getAutoStartConfigs()`), not from the state file. `runDaemonChild({ skipAutoStart: true })` leaves them out: a host sets it when it restarts a daemon after a crash, so an auto-start tunnel the user had stopped stays stopped.
|
|
292
292
|
|
|
293
|
-
The background device agent is not in this file either. `deviceAgent` (`{startedAt, startedBy}`) in `daemon-config.json` survives a clean shutdown, so every daemon start runs the agent: after a crash, a `pinggy daemon stop`, or a reboot with `pinggy
|
|
293
|
+
The background device agent is not in this file either. `deviceAgent` (`{startedAt, startedBy}`) in `daemon-config.json` survives a clean shutdown, so every daemon start runs the agent: after a crash, a `pinggy daemon stop`, or a reboot with `pinggy autostart on`. See section 17.
|
|
294
294
|
|
|
295
295
|
## 9. Tunnel lifecycle end-to-end
|
|
296
296
|
|
|
@@ -369,7 +369,7 @@ src/
|
|
|
369
369
|
│ ├── buildAndStartTunnel.ts Legacy single-tunnel path
|
|
370
370
|
│ ├── buildConfig.ts CLI flags + positionals → FinalConfig
|
|
371
371
|
│ ├── configStore.ts Persisted saved-config CRUD
|
|
372
|
-
│ ├── daemonCommands.ts `pinggy daemon start|stop|status
|
|
372
|
+
│ ├── daemonCommands.ts `pinggy daemon start|stop|status`, and the old service verbs
|
|
373
373
|
│ ├── attachCommand.ts `pinggy attach`
|
|
374
374
|
│ ├── psCommand.ts `pinggy ps`
|
|
375
375
|
│ ├── stopCommand.ts `pinggy stop`
|
|
@@ -490,15 +490,25 @@ CLI logs (the short-lived foreground process) go to stdout by default. The daemo
|
|
|
490
490
|
|
|
491
491
|
Same code path as user-typed subcommands: the daemon does not know or care that the request came from remote management.
|
|
492
492
|
|
|
493
|
-
## 16. Service installation
|
|
493
|
+
## 16. Service installation (`pinggy autostart`)
|
|
494
494
|
|
|
495
|
-
`pinggy
|
|
495
|
+
`pinggy autostart on` writes a platform-specific boot entry and enables it. `pinggy autostart off` removes it and stops nothing. `pinggy device remove` removes it too. Code: `src/daemon/lifecycle/serviceInstaller.ts` (the entry), `src/devices/autostart.ts` (the command). `pinggy daemon service-install` and `service-uninstall`, the old names, print the new command and exit 1 (`renamedDaemonVerbMessage()`).
|
|
496
496
|
|
|
497
|
-
|
|
498
|
-
- macOS: launchd `LaunchAgent` at `~/Library/LaunchAgents/io.pinggy.agent.plist`. `launchctl load`.
|
|
499
|
-
- Windows: Task Scheduler task `PinggyDaemon`, created with `schtasks /Create` and no admin rights. A logon trigger for the current user runs `<binary> daemon start`. `daemon start` spawns `--_daemon-child` detached with `windowsHide`, then exits. The task does not run `--_daemon-child` directly: `pinggy.exe` is a console program, so Task Scheduler opens a console window for it, and closing that window kills the daemon. The `daemon start` window shows for about 1s. The task ends once the daemon is up, so uninstall stops the daemon over IPC. It deletes the task first, so a failed delete leaves the daemon running. With no task, it stops nothing. A task created from an Administrator terminal keeps admin-only permissions, so a normal terminal cannot replace or delete it. When `schtasks` fails, the task exists, and `whoami /groups` shows no High or System integrity SID, pinggy tells the user to run the command from an Administrator terminal. It checks the SID, not the "Access is denied" text, because `schtasks` prints that text in the Windows language.
|
|
497
|
+
A restart brings the device back only when the boot entry and the saved agent (`deviceAgent` in `daemon-config.json`, section 17) both exist. `isAutostartOn()` checks both, for `autostart status` and the `Autostart` row of `pinggy device status`. `on` runs in this order, and a failed step writes no entry:
|
|
500
498
|
|
|
501
|
-
|
|
499
|
+
1. No `device.json`: refuse, naming `pinggy device login`.
|
|
500
|
+
2. `serviceInstallRefusal()`: the npm copy, or a binary that is not the installed one.
|
|
501
|
+
3. No saved agent: refuse while a `--foreground` agent runs. With no terminal, refuse and name `pinggy device start`. Otherwise ask "Start it now, and each time this computer starts? [Y/n]". Yes runs the `pinggy device start` path, which saves the agent.
|
|
502
|
+
4. An entry that already runs `serviceProgramPath()`: print "already on" and change nothing. `bootEntryProgram()` reads the program back from the unit, the plist or `schtasks /Query /XML`.
|
|
503
|
+
5. Write the entry and start it.
|
|
504
|
+
|
|
505
|
+
`off` never stops the daemon. Run from the dashboard's browser terminal, a stop would end that terminal and take the device offline. The device stays online until the next restart, and `pinggy device stop` takes it offline now.
|
|
506
|
+
|
|
507
|
+
- Linux: systemd user unit at `~/.config/systemd/user/pinggy.service`. `Type=simple`, runs `<binary> --_daemon-child` directly (no fork). `systemctl --user enable`, then `start`, which leaves a running unit alone. A user unit starts at sign-in, so `on` then runs `loginctl enable-linger <user>`, unless `loginctl show-user` reports `Linger=yes`. Lingering starts the user's units at boot, with nobody signed in. When the command fails, as on a system that wants an admin password for it, `on` prints the command and still exits 0. `off` runs `disable`, deletes the unit and runs `daemon-reload`, with no `stop`: systemd keeps a running unit whose file is gone until it exits. `off` leaves lingering on, because it belongs to the user and other units may need it.
|
|
508
|
+
- macOS: launchd `LaunchAgent` at `~/Library/LaunchAgents/io.pinggy.agent.plist`. Starts at sign-in. `on` runs `launchctl bootstrap gui/<uid>`, or `kickstart` without `-k` when the job is still loaded after an `off`, and never `bootout`, which would stop the job's daemon. `off` deletes the plist only: launchd keeps the job loaded until sign-out, and the next sign-in finds no plist.
|
|
509
|
+
- Windows: Task Scheduler task `PinggyDaemon`, created with `schtasks /Create` and no admin rights. Starts at sign-in. A logon trigger for the current user runs `<binary> daemon start`. `daemon start` spawns `--_daemon-child` detached with `windowsHide`, then exits. The task does not run `--_daemon-child` directly: `pinggy.exe` is a console program, so Task Scheduler opens a console window for it, and closing that window kills the daemon. The `daemon start` window shows for about 1s. `off` deletes the task and leaves the daemon running. A task created from an Administrator terminal keeps admin-only permissions, so a normal terminal cannot replace or delete it. When `schtasks` fails, the task exists, and `whoami /groups` shows no High or System integrity SID, pinggy tells the user to run the command from an Administrator terminal. It checks the SID, not the "Access is denied" text, because `schtasks` prints that text in the Windows language.
|
|
510
|
+
|
|
511
|
+
The entry stores the full path of the binary (`process.execPath`). If the user moves or deletes that file, the entry fails at login with no message. So `on` writes it only from the path the install scripts write: `%LOCALAPPDATA%\Pinggy\bin\pinggy.exe` on Windows, `~/.pinggy/bin/pinggy` on Linux and macOS (`installerBinaryPath()`). The scripts update the binary in place, so the stored path stays valid. From any other path it prints the install script command and exits 1. From an npm install it prints `npm uninstall -g pinggy` first, because the install script updates an npm copy with npm. The message names no paths, except when the installed copy exists: then it names that copy and the command to run with it, because a downloaded binary can install itself and then run `autostart on` in the same process. `PINGGY_SERVICE_ANY_LOCATION=1` skips the path check, for development and CI. It does not allow npm installs. `off` runs from any path. On Linux and macOS, `on` starts the service at once, and the service runs `--_daemon-child`. When a daemon already runs, for example after `pinggy device login`, the service's daemon finds `daemon.lock` held and exits 0, so 1 daemon and 1 device agent stay. On Windows the task runs `daemon start`, which finds the running daemon and exits. Changing the install directory in either script means changing `installerBinaryPath()` in the same commit.
|
|
502
512
|
|
|
503
513
|
A system service gives restart-on-failure and start-at-login. The plain daemon mode does not.
|
|
504
514
|
|
|
@@ -510,9 +520,9 @@ The one long-lived surface that is not a tunnel. `pinggy device connect` enrols
|
|
|
510
520
|
|
|
511
521
|
**Email sign-in.** `pinggy device login` gets the device token without the dashboard: it asks for an email, `POST /backend/api/v1/device-agent/login/start` emails a 6-digit code, and the code prompt races a `poll` every few seconds under 1 `AbortController`. A right code (and the TOTP, with MFA on) answers the token once. The email also carries an Approve link: the CLI prints the `match_code` its page shows as `Device Code: <code>`, then `We have sent a 6-digit code to <email>.` and `Enter the code below or click the approve button in the email.` A poll collects a link's approval, and a typed code answered `pending` stops the prompt so the poll can. The CLI writes `device.json`, prints the device's browser link and its QR code (`createQrCodes`, shared with the TUI): a one-time sign-in link after a typed code, the plain device page after the emailed link. Then it runs the same agent. Code in `src/devices/login/`: `deviceLogin.ts` (the command; every dependency injected, so `src/_tests_/deviceLogin.test.ts` runs it with no dashboard or terminal), `loginApi.ts` (`fetch`, `buildDashboardHttpUrl`, the public client token), `login_schema.ts` (zod), `prompts.ts` (`readline/promises`, 1 interface per question, closed on answer or abort; every question starts with a cyan `→`, and the sign-in result with a green one, through `picocolors`; `askHidden` reads the authenticator code without showing it, since the code still works after it is typed and the open link asks for one). A stdin that is not a TTY stops at once and points at `connect --token`. The token is never printed.
|
|
512
522
|
|
|
513
|
-
**Install scripts.** `scripts/install/install.sh` (macOS, Linux, POSIX `sh`) and `scripts/install/install.ps1` (Windows PowerShell 5.1 and 7) install or update the binary, put `pinggy` on PATH with no sudo, then ask "Connect this device to Pinggy? [Y/n]". Enter or `y` runs `pinggy device login -b` by full path. `-b` is the default, and the scripts pass it so an older binary the user kept also runs the agent in its daemon. An answer starting with `n` prints the login command and exits 0, so the CLI is installed with no device. With no terminal, the scripts ask nothing and print the command. `install.sh` writes `~/.pinggy/bin/pinggy` and links `~/.local/bin/pinggy` to it, adding 1 marked block to the shell's rc file when `~/.local/bin` is not on PATH. `install.ps1` writes `%LOCALAPPDATA%\Pinggy\bin\pinggy.exe` and adds that directory to the user PATH. Both read the version to install from `https://pinggy.io/cli/version.json`, never from GitHub's `/releases/latest`. The website builds that file from `data/cli_releases.yaml`, and the release PR changes that list and both scripts in 1 commit, so the script and the binary come from 1 release. When pinggy.io does not answer, or the file has no `x.y.z` in its `version` field, the scripts exit 1 with a message that names the URL and `PINGGY_VERSION`. `PINGGY_VERSION` skips the request. The binary still downloads from the GitHub release. `install.sh` reads the field with `sed`, so the key stays `version` with a quoted value. Both read 3 things this repo owns: the release asset names, the `Pinggy CLI version: <x.y.z>` line, and the `--manage` and `-b` flags of `device login` and `connect`. A change to any of them changes both scripts in the same commit. `.github/workflows/website-cli-download-links-pr.yml` copies both, read at the release tag, to the website's `static/`, so pinggy.io serves `/install.sh` and `/install.ps1`. After `device login` or `connect` exits 0, both scripts ask "Start pinggy automatically when this computer starts? [Y/n]" and run `pinggy
|
|
523
|
+
**Install scripts.** `scripts/install/install.sh` (macOS, Linux, POSIX `sh`) and `scripts/install/install.ps1` (Windows PowerShell 5.1 and 7) install or update the binary, put `pinggy` on PATH with no sudo, then ask "Connect this device to Pinggy? [Y/n]". Enter or `y` runs `pinggy device login -b` by full path. `-b` is the default, and the scripts pass it so an older binary the user kept also runs the agent in its daemon. An answer starting with `n` prints the login command and exits 0, so the CLI is installed with no device. With no terminal, the scripts ask nothing and print the command. `install.sh` writes `~/.pinggy/bin/pinggy` and links `~/.local/bin/pinggy` to it, adding 1 marked block to the shell's rc file when `~/.local/bin` is not on PATH. `install.ps1` writes `%LOCALAPPDATA%\Pinggy\bin\pinggy.exe` and adds that directory to the user PATH. Both read the version to install from `https://pinggy.io/cli/version.json`, never from GitHub's `/releases/latest`. The website builds that file from `data/cli_releases.yaml`, and the release PR changes that list and both scripts in 1 commit, so the script and the binary come from 1 release. When pinggy.io does not answer, or the file has no `x.y.z` in its `version` field, the scripts exit 1 with a message that names the URL and `PINGGY_VERSION`. `PINGGY_VERSION` skips the request. The binary still downloads from the GitHub release. `install.sh` reads the field with `sed`, so the key stays `version` with a quoted value. Both read 3 things this repo owns: the release asset names, the `Pinggy CLI version: <x.y.z>` line, and the `--manage` and `-b` flags of `device login` and `connect`. A change to any of them changes both scripts in the same commit. `.github/workflows/website-cli-download-links-pr.yml` copies both, read at the release tag, to the website's `static/`, so pinggy.io serves `/install.sh` and `/install.ps1`. After `device login` or `connect` exits 0, both scripts ask "Start pinggy automatically when this computer starts? [Y/n]" and run `pinggy autostart on`. A script run with `PINGGY_VERSION` set to a release before `pinggy autostart` gets "Could not turn on autostart" there, and the install still succeeds. The question says "starts" for users. On macOS and Windows the service starts pinggy after the user signs in, not at boot. On Linux it starts at boot, because `on` turns on lingering. They skip the question when the service exists and runs the installed binary: `install.sh` looks for that binary's path in the launchd plist or the systemd unit file, `install.ps1` compares the command of the `PinggyDaemon` task (`Get-ScheduledTask`) with it. A service that runs any other binary gets the question, and `on` replaces it. `install.sh` also skips it on Linux with no systemd user manager. With no terminal, they print the `pinggy autostart on` command. They remove `DEVICE_AGENT_TOKEN` before the question. Renaming the task, the plist or the unit file changes both scripts in the same commit. Before each request the user waits on, both scripts print what it does: `Checking the latest version of Pinggy...` before `version.json`, and `Checking the latest version of pinggy on npm...` before `npm view`. Each request has a stall check and no limit on its total time. curl gets `--speed-limit 1 --speed-time 60`: it gives up when less than 1 byte per second arrives for 60 s. wget gets `--read-timeout=60 --tries=2`. The OS still ends a connection attempt with no answer, and curl a stalled TLS handshake after 5 min. Windows PowerShell 5.1 has no stall check, so `install.ps1` gives the version request `-TimeoutSec 60` and the binary download no limit. `install.sh` prints `Downloading pinggy <version> for <os>-<cpu>` and runs the download in the background. With a terminal on stderr, it rewrites 1 line each second, ` 23.4 MB of 61.5 MB (38%)`. The total comes from the `Content-Length` of the 2xx response in the file curl writes with `-D`, since GitHub's redirect sends `Content-Length: 0` first. curl's own `--progress-bar` drew an unknown-size animation during that redirect, and drew 79 columns under `curl | sh`, which gives curl no terminal width. curl's errors go to a file and print after the line ends. wget shows the size with no total. `install.ps1` downloads with no progress line. After the install, before the sign-in, both scripts offer a daemon restart. They read `pid`, `host` and `cliVersion` from `daemon.json`. When the pid runs `--_daemon-child`, `host` is not `app`, and `cliVersion` differs from what the copy they sign in with prints, they ask "Restart it with <version>? [Y/n]". Yes restarts the daemon the way `serviceRestartInstruction()` names: `launchctl kickstart -k gui/<uid>/io.pinggy.agent` when launchd's process is the daemon, `systemctl --user restart pinggy` when systemd's is. Otherwise, and always on Windows, they run `pinggy daemon stop`, wait up to 10 s for the pid to end, and run `pinggy daemon start`. The restart runs without `DEVICE_AGENT_TOKEN`, because a daemon copies the environment of the command that starts it. Then they read `daemon.json` again and print `The pinggy daemon now runs <version>.` or the restart command. No, or no terminal, restarts nothing and prints the restart command. Tunnels started with `-b` or from the dashboard stop with the old daemon, because a clean stop deletes `daemon-state.json`. Auto-start tunnels and the device agent start again. `PINGGY_INSTALL_ONLY=1` skips the question. Lint with `shellcheck -s sh` and `PSScriptAnalyzer`.
|
|
514
524
|
|
|
515
|
-
**Which copy the scripts update.** Both scripts update the copy that the `pinggy` command runs in that terminal: `command -v pinggy` with every link resolved in `install.sh` (a `readlink` loop and `cd -P`, since macOS before 13 has no `realpath`), and the first `Get-Command pinggy` in `install.ps1`. No copy, or the scripts' own binary, gets the binary flow above. An npm copy is a real path under `<prefix>/lib/node_modules/pinggy/`, or on Windows a launcher folder that holds `node_modules\pinggy\package.json` and no junction there. The scripts update it with `npm install -g --prefix <prefix> pinggy@<version>`, with the version from `npm view pinggy version`, because npm publishes in a separate job. `--prefix` updates that copy even when the `npm` on PATH uses another global folder. The npm flow writes no binary and no PATH, signs in with npm's copy by full path (`pinggy.cmd` on Windows, since an execution policy can block `pinggy.ps1`), and skips the login service question with no message, because `
|
|
525
|
+
**Which copy the scripts update.** Both scripts update the copy that the `pinggy` command runs in that terminal: `command -v pinggy` with every link resolved in `install.sh` (a `readlink` loop and `cd -P`, since macOS before 13 has no `realpath`), and the first `Get-Command pinggy` in `install.ps1`. No copy, or the scripts' own binary, gets the binary flow above. An npm copy is a real path under `<prefix>/lib/node_modules/pinggy/`, or on Windows a launcher folder that holds `node_modules\pinggy\package.json` and no junction there. The scripts update it with `npm install -g --prefix <prefix> pinggy@<version>`, with the version from `npm view pinggy version`, because npm publishes in a separate job. `--prefix` updates that copy even when the `npm` on PATH uses another global folder. The npm flow writes no binary and no PATH, signs in with npm's copy by full path (`pinggy.cmd` on Windows, since an execution policy can block `pinggy.ps1`), and skips the login service question with no message, because `pinggy autostart on` refuses the npm version. A broken npm copy, one that prints no `Pinggy CLI version:` line, gets "Reinstall it with npm? [Y/n]". On macOS and Linux, a folder the user cannot write stops the script with the `sudo npm install -g --prefix` command. On Windows, when the update fails while `%APPDATA%\pinggy\daemon.json` names a live process, `install.ps1` asks "pinggy is running. Stop it and all its tunnels, then retry? [Y/n]". With no terminal that answer is no. A program file the scripts did not install, such as a binary downloaded by hand, gets "Install the latest pinggy, <version>, to ~/.pinggy/bin/pinggy? [Y/n]". No signs in with that file and skips the login service question. A script file, one that starts with `#!` (`npm link`, pnpm, yarn, bun), stops the script with exit 1 and names the command's path. bun's Windows launcher is a `pinggy.exe` beside a `pinggy.bunx`, and counts as a script. `PINGGY_BINARY_URL` skips the check and installs that file.
|
|
516
526
|
|
|
517
527
|
**A downloaded binary installs itself.** `offerSelfInstall()` in `src/install/selfInstall.ts` runs in `main.ts` before the background update. A packaged binary that is not the installed copy (`UnixLayout` or `UnixPlainFile`, or on Windows any file in `%LOCALAPPDATA%\Pinggy\bin`) asks 1 question when stdin and stdout are terminals. With nothing installed, or when `pinggy` runs a copy it cannot remove (`npm link`, pnpm, yarn, bun, another binary): "Install this pinggy, X, to ~/.pinggy/bin/pinggy? [Y/n]". With the scripts' binary installed, whatever its version: "pinggy X is installed in ~/.pinggy/bin/pinggy. Replace it with this pinggy, Y? [Y/n]". When `pinggy` runs an npm copy, whatever its version: "pinggy X is installed with npm. Remove it, and install this pinggy, Y, to ~/.pinggy/bin/pinggy? [Y/n]". The versions are printed and never compared, so an older file can replace a newer install, and the same version asks again. `src/install/pinggyOnPath.ts` finds the copy with the scripts' npm rules and never counts the current folder. No question for `--version`, `--help` or `pinggy update`, under sudo, in a container, while `update.lock` is held, when `update.json` cannot be written, or for a file and version the user said `n` to (`declinedInstallPath`, `declinedInstallVersion`). Yes copies the install script the binary carries in `pkg.assets` to a private temp folder and runs it with `PINGGY_BINARY_URL` naming this file and `PINGGY_INSTALL_ONLY=1`, which ends the script after the install, with no sign-in and no PATH warning. So the files match the scripts' layout exactly. `install.ps1` runs through `iex`, so an execution policy that blocks script files does not block it. For an npm copy the binary installs first, then runs `npm uninstall -g --prefix <prefix> pinggy`, and prints the `sudo` command for a folder it cannot write. It prints the PATH warning itself, then runs the user's command in the same process. A daemon that command starts runs from the installed copy (`startDaemonFromInstalledBinary()`). The installed binary's version comes from its link target, with no process. A plain file's or the Windows binary's `--version` output is kept in `update.json` with the file's size and modified time. Ctrl+D answers nothing, and a failed install counts as `n`. A double-clicked `pinggy.exe` ends with "Press Enter to close.", and the Windows updater moves a remembered `n` to the new version when it replaces that file in place. In the scripts' own case 7, after `n`, sign-in runs the user's binary, which can ask its own question once.
|
|
518
528
|
|
|
@@ -526,7 +536,7 @@ The design lives in the `pinggy_backend` repo under `docs/pinggy-devices/`: `cli
|
|
|
526
536
|
|
|
527
537
|
### Background mode
|
|
528
538
|
|
|
529
|
-
`pinggy device connect` and `pinggy device login` hand the agent to the daemon, as `pinggy start -b` hands it a tunnel, and exit once the device connects. This is the default. `--foreground` (`cliOptions.foreground`, hidden) keeps the agent in the CLI process. `-b` (`cliOptions.b`) still parses and changes nothing. `-b` with `--foreground` exits 1 before anything runs. Whoever hosts the daemon hosts the agent: the CLI's detached child, `pinggy
|
|
539
|
+
`pinggy device connect` and `pinggy device login` hand the agent to the daemon, as `pinggy start -b` hands it a tunnel, and exit once the device connects. This is the default. `--foreground` (`cliOptions.foreground`, hidden) keeps the agent in the CLI process. `-b` (`cliOptions.b`) still parses and changes nothing. `-b` with `--foreground` exits 1 before anything runs. Whoever hosts the daemon hosts the agent: the CLI's detached child, the boot entry `pinggy autostart on` writes, or the Pinggy app, whose in-process daemon runs the same `runDaemonChild()`. The app reaches it through `TunnelClient.getDeviceAgentStatus()`, `startDeviceAgent()` and `stopDeviceAgent()`.
|
|
530
540
|
|
|
531
541
|
**The token never goes over IPC.** `device.json` is the hand-off: the CLI writes it, the daemon reads it. The 3 `/device` routes (section 5) read no request field. A target that differs from `device.json` (another token, or another server) is checked first in the CLI with `startDeviceAgent(..., { verifyOnly: true })`: 1 attempt, ended at `welcome`, which writes `device.json` as the foreground agent does. A token the dashboard refuses never reaches the file or the daemon.
|
|
532
542
|
|
|
@@ -541,11 +551,11 @@ The design lives in the `pinggy_backend` repo under `docs/pinggy-devices/`: `cli
|
|
|
541
551
|
|
|
542
552
|
`login` signs in as the foreground does, then runs steps 3 to 6 in place of `runAgent`. After a new sign-in, `runAgent` gets `signInShown`, and step 6 leaves out the email and the device link, which the sign-in already printed. `device stop` calls `POST /device/stop`. `device status` prints a `State` line first (`describeDeviceState()`). It reads `GET /device` once, and `device-agent.json`: `running` plus the daemon agent's connection state, `running, with --foreground in another terminal`, `stopped` when no agent runs or no daemon runs, or `unknown` when `daemon.json` names a daemon that `GET /device` cannot read (another IPC version, an older daemon, no answer). It adds a `Background` line from the same reading. `device remove` stops a running background agent before it deletes `device.json`. A `--foreground` `connect` or `login` refuses while `GET /device` reports a run: 2 agents on 1 credential refuse each other with `already_connected`.
|
|
543
553
|
|
|
544
|
-
**The foreground record** (`src/devices/foregroundAgent.ts`). The daemon cannot see an agent started with `--foreground`, so `runDeviceAgent()` writes `device-agent.json` (`{pid, started_at, boot_id}`) beside `device.json` while it runs, and deletes it on exit if it still names its own PID. The agent checks once a second that the file exists. `device remove` (`src/devices/removeDevice.ts`) first prints the device id, the background agent's state and the foreground record's PID, and asks "Remove this device from this machine? [y/N]". Only `y` or `yes` goes on. `-f`, the existing `cliOptions.force`, skips the question. With no TTY and no `-f`, it exits 1 and changes nothing. Then it deletes the file, waits up to 10 s for the PID to exit, and deletes `device.json`. An agent still running after that fails the remove with exit 1 and leaves `device.json` in place. No signal goes to the PID: a record left by a crash can name an unrelated process. `readForegroundAgent()` deletes a record whose PID is dead or that comes from an earlier boot (section 3, "The boot check"). `connect` and `login` refuse while a live record names another process, both in the default background start and with `--foreground`. The background start writes no record: the daemon's `GET /device` already reports it. `device status` adds a `Foreground` line.
|
|
554
|
+
**The foreground record** (`src/devices/foregroundAgent.ts`). The daemon cannot see an agent started with `--foreground`, so `runDeviceAgent()` writes `device-agent.json` (`{pid, started_at, boot_id}`) beside `device.json` while it runs, and deletes it on exit if it still names its own PID. The agent checks once a second that the file exists. `device remove` (`src/devices/removeDevice.ts`) first prints the device id, the background agent's state and the foreground record's PID, and asks "Remove this device from this machine? [y/N]". Only `y` or `yes` goes on. `-f`, the existing `cliOptions.force`, skips the question. With no TTY and no `-f`, it exits 1 and changes nothing. Then it deletes the file, waits up to 10 s for the PID to exit, and deletes `device.json`. Last it removes the boot entry (section 16), which the question names when one exists. An agent still running after that fails the remove with exit 1 and leaves `device.json` in place. No signal goes to the PID: a record left by a crash can name an unrelated process. `readForegroundAgent()` deletes a record whose PID is dead or that comes from an earlier boot (section 3, "The boot check"). `connect` and `login` refuse while a live record names another process, both in the default background start and with `--foreground`. The background start writes no record: the daemon's `GET /device` already reports it. `device status` adds a `Foreground` line.
|
|
545
555
|
|
|
546
556
|
**`DeviceAgentHost`** (`src/daemon/deviceAgentHost.ts`) holds at most 1 run, built in `runDaemonChild()` once the IPC port is known. `start(origin)` reads `device.json`: none answers `DEVICE_NOT_ENROLLED`, a run on the same token and server is left alone, and a run on another is stopped before the new one starts. Start and stop run 1 at a time through 1 promise chain. A run that ends on its own (401, revoked, deleted, replaced) keeps why in `lastError`. The host saves the run in `daemon-config.json` through `saveDeviceAgent()`, and forgets it through `forgetDeviceAgent()` on a terminal outcome. A stop keeps it saved: `device stop` ends the current run only. `close()` on shutdown records nothing, so the run stays saved.
|
|
547
557
|
|
|
548
|
-
**Start with the daemon.** After the auto-start tunnels, `startSavedDeviceAgent()` in `runDaemonChild()` starts the saved agent with its `startedBy`. This runs on every daemon start, the way auto-start tunnels do, so the Pinggy app's in-process daemon starts it too. It skips the start while `device-agent.json` names a live foreground agent: 2 agents on 1 credential refuse each other with `already_connected`. The record stays for the next start. With no `device.json`, the start fails with `DEVICE_NOT_ENROLLED` and the record is deleted. Only `pinggy device remove` deletes the record from the CLI, before it deletes `device.json`. `pinggy device status` prints `Autostart on` while the record
|
|
558
|
+
**Start with the daemon.** After the auto-start tunnels, `startSavedDeviceAgent()` in `runDaemonChild()` starts the saved agent with its `startedBy`. This runs on every daemon start, the way auto-start tunnels do, so the Pinggy app's in-process daemon starts it too. It skips the start while `device-agent.json` names a live foreground agent: 2 agents on 1 credential refuse each other with `already_connected`. The record stays for the next start. With no `device.json`, the start fails with `DEVICE_NOT_ENROLLED` and the record is deleted. Only `pinggy device remove` deletes the record from the CLI, before it deletes `device.json`. `pinggy device status` prints `Autostart on` only while the record and the boot entry (section 16) both exist: the record alone starts nothing after a reboot. A `--foreground` agent never writes it.
|
|
549
559
|
|
|
550
560
|
The daemon's run differs from the foreground one in 3 dependencies, passed through `DeviceAgentOptions`:
|
|
551
561
|
|
|
@@ -558,7 +568,7 @@ The daemon's run differs from the foreground one in 3 dependencies, passed throu
|
|
|
558
568
|
| The CLI that ran `connect` exits, or its terminal closes | Keeps running. The daemon is detached |
|
|
559
569
|
| Daemon crash | Starts again with the next daemon |
|
|
560
570
|
| `pinggy daemon stop`, or the Pinggy app quits | Stops. The socket closes with 1000 and every shell ends. Starts again with the next daemon |
|
|
561
|
-
| Reboot | Starts again when the daemon starts, at sign-in with `pinggy
|
|
571
|
+
| Reboot | Starts again when the daemon starts: at boot on Linux, at sign-in on macOS and Windows, with `pinggy autostart on` |
|
|
562
572
|
| `pinggy device stop` | Stops. Starts again with the next daemon |
|
|
563
573
|
| `pinggy device remove` | Stops, and the daemon never starts it again |
|
|
564
574
|
| A terminal outcome | Stops, with `lastError`, and stays stopped until the next `connect` or `login` |
|
|
@@ -593,10 +603,10 @@ The daemon's run differs from the foreground one in 3 dependencies, passed throu
|
|
|
593
603
|
| `src/devices/terminal/ptySession.ts` | Lazy `node-pty` load, `isTerminalSupported()` (false unless the addon loads and, on macOS, `spawn-helper` can be exec'd), `spawnPty()`, the `spawn-helper` execute-bit repair, `signalForeground()` to the tty's foreground process group |
|
|
594
604
|
| `src/devices/terminal/nodePtyRuntime.ts` | `resolveNodePtyRoot()`: where `node-pty` loads from. Unpacks it onto real disk inside a `pkg` binary or an Electron `.asar` archive, into a directory named by the addon's hash. `hasExecutableSpawnHelper()`, true off macOS |
|
|
595
605
|
| `src/devices/terminal/shellAllowlist.ts` | `resolveShell()`: exact match against `/etc/shells`, or `powershell.exe` and `cmd.exe` on Windows |
|
|
596
|
-
| `src/cli/subcommand/handlers/deviceCommand.ts` | The `login`, `connect`, `stop`, `status`, `remove` verbs, `--foreground` and `--files`. `refuseDevicesSpelling()` for the old spelling |
|
|
597
|
-
| `src/utils/helpMessages.ts` | `printDeviceHelp()` |
|
|
606
|
+
| `src/cli/subcommand/handlers/deviceCommand.ts` | The `login`, `connect`, `stop`, `status`, `remove` verbs, `--foreground` and `--files`. `refuseDevicesSpelling()` for the old spelling. `handleAutostart()` for `pinggy autostart` |
|
|
607
|
+
| `src/utils/helpMessages.ts` | `printDeviceHelp()`, `printAutostartHelp()` |
|
|
598
608
|
|
|
599
|
-
`Subcommand.Device` in `src/cli/configStore.ts` puts `device` in `SUBCOMMANDS` and `RESERVED_NAMES`, so no new saved tunnel config can be named `device`. `Subcommand.Devices` keeps the old spelling in both. `pinggy devices` prints `"pinggy devices" is now "pinggy device". Run: pinggy device <verb>` and exits 1. It names the verb only when it is 1 of the 5, else `--help`, and never repeats the other arguments, which can hold a token. Without it, `devices` would fall to legacy tunnel mode, where `--token` is the tunnel token, and a device token would reach the tunnel server.
|
|
609
|
+
`Subcommand.Device` in `src/cli/configStore.ts` puts `device` in `SUBCOMMANDS` and `RESERVED_NAMES`, so no new saved tunnel config can be named `device`. `Subcommand.Autostart` does the same for `autostart`. `Subcommand.Devices` keeps the old spelling in both. `pinggy devices` prints `"pinggy devices" is now "pinggy device". Run: pinggy device <verb>` and exits 1. It names the verb only when it is 1 of the 5, else `--help`, and never repeats the other arguments, which can hold a token. Without it, `devices` would fall to legacy tunnel mode, where `--token` is the tunnel token, and a device token would reach the tunnel server.
|
|
600
610
|
|
|
601
611
|
### The envelope
|
|
602
612
|
|
package/CLAUDE.md
CHANGED
|
@@ -28,7 +28,7 @@ node test/e2e/run.cjs out/pinggy-<platform>
|
|
|
28
28
|
The CLI binary has 4 entry modes, dispatched in `src/main.ts`:
|
|
29
29
|
|
|
30
30
|
1. **Daemon child** (`--_daemon-child` flag). Calls `runDaemonChild()` in `src/daemon/daemonChild.ts`. The CLI re-execs itself with this flag when it needs to spawn a daemon; users never invoke it directly.
|
|
31
|
-
2. **Subcommand** (`config`, `start`, `stop`, `ps`, `attach`, `daemon`, `d`, `device`, `devices`, `update`). Routes to `handleSubcommand()` in `src/cli/subcommands.ts`.
|
|
31
|
+
2. **Subcommand** (`config`, `start`, `stop`, `ps`, `attach`, `daemon`, `d`, `device`, `devices`, `update`, `autostart`). Routes to `handleSubcommand()` in `src/cli/subcommands.ts`.
|
|
32
32
|
3. **Legacy single-tunnel** (no subcommand). Routes to `buildAndStartTunnel()` for flags like `-l 3000` or `-R0:localhost:3000`.
|
|
33
33
|
4. **Update child** (`--_update-child` flag). Calls `runUpdateChild()` in `src/update/updateChild.ts`. A command starts it at most once a day, detached, to check for a release and install it.
|
|
34
34
|
|
|
@@ -83,7 +83,7 @@ It owns no tunnel. It reads the daemon's `GET /tunnels` through `IPCClient` and
|
|
|
83
83
|
|
|
84
84
|
1 invocation runs 1 subcommand: `isSubcommand()` reads `rawArgs[0]` only, so `pinggy device connect start my-tunnel` runs the agent and drops the rest, and tunnel flags on a `device` line parse and are ignored, except `-b` and `--foreground`.
|
|
85
85
|
|
|
86
|
-
`scripts/install/install.sh` installs into `~/.pinggy/versions/<version>/` and points the link `~/.pinggy/bin/pinggy` at it. `install.sh` and `install.ps1` install or update the binary, put it on PATH, then ask "Connect this device to Pinggy? [Y/n]" and run `pinggy device login -b` unless the answer starts with `n`. `-b` is the default, and the scripts pass it so an older binary the user kept also runs the agent in its daemon. pinggy.io serves copies that `website-cli-download-links-pr.yml` writes at each release tag. The scripts read the version to install from `https://pinggy.io/cli/version.json`, which the website builds from the `data/cli_releases.yaml` that the same PR updates, and they exit 1 when it does not answer. They download the binary from the GitHub release. The updater in `src/update/` still reads GitHub's `/releases/latest`. Copies of the scripts stay in use, so that URL and its `version` field never change. Renaming a release asset, changing the `Pinggy CLI version:` line, or changing `device login`'s `--manage` or `-b` flag means changing both scripts in the same commit. `DEVICE_AGENT_TOKEN` on either script still gets every update question, then runs `pinggy device connect -b` instead, with the token in the environment, never on a command line. `install.sh` gives `connect` `/dev/tty` as stdin when it has a terminal, so `connect` can ask the file access question, and `/dev/null` otherwise; never its own stdin, which under `curl | sh` holds the rest of the script. `handleDevice()` deletes the variable from `process.env` before any verb runs, so no shell or daemon the agent starts inherits it. Renaming the variable or `connect`'s `--manage` or `-b` flag also changes both scripts in the same commit. Both scripts update the copy the `pinggy` command runs: an npm copy with `npm install -g --prefix`, the binary otherwise. A copy from `npm link`, pnpm, yarn or bun stops them, and a binary they did not install gets a question first (ARCHITECTURE.md, "Which copy the scripts update"). They tell an npm copy by the `lib/node_modules/pinggy/` path that npm writes. A packaged binary run from anywhere else offers to install itself by running the script it carries, with `PINGGY_BINARY_URL` and `PINGGY_INSTALL_ONLY=1` (`src/install/selfInstall.ts`). It finds the copy `pinggy` runs in `src/install/pinggyOnPath.ts`, so a change to how either script tells an npm copy changes that file in the same commit. `pinggy
|
|
86
|
+
`scripts/install/install.sh` installs into `~/.pinggy/versions/<version>/` and points the link `~/.pinggy/bin/pinggy` at it. `install.sh` and `install.ps1` install or update the binary, put it on PATH, then ask "Connect this device to Pinggy? [Y/n]" and run `pinggy device login -b` unless the answer starts with `n`. `-b` is the default, and the scripts pass it so an older binary the user kept also runs the agent in its daemon. pinggy.io serves copies that `website-cli-download-links-pr.yml` writes at each release tag. The scripts read the version to install from `https://pinggy.io/cli/version.json`, which the website builds from the `data/cli_releases.yaml` that the same PR updates, and they exit 1 when it does not answer. They download the binary from the GitHub release. The updater in `src/update/` still reads GitHub's `/releases/latest`. Copies of the scripts stay in use, so that URL and its `version` field never change. Renaming a release asset, changing the `Pinggy CLI version:` line, or changing `device login`'s `--manage` or `-b` flag means changing both scripts in the same commit. `DEVICE_AGENT_TOKEN` on either script still gets every update question, then runs `pinggy device connect -b` instead, with the token in the environment, never on a command line. `install.sh` gives `connect` `/dev/tty` as stdin when it has a terminal, so `connect` can ask the file access question, and `/dev/null` otherwise; never its own stdin, which under `curl | sh` holds the rest of the script. `handleDevice()` deletes the variable from `process.env` before any verb runs, so no shell or daemon the agent starts inherits it. Renaming the variable or `connect`'s `--manage` or `-b` flag also changes both scripts in the same commit. Both scripts update the copy the `pinggy` command runs: an npm copy with `npm install -g --prefix`, the binary otherwise. A copy from `npm link`, pnpm, yarn or bun stops them, and a binary they did not install gets a question first (ARCHITECTURE.md, "Which copy the scripts update"). They tell an npm copy by the `lib/node_modules/pinggy/` path that npm writes. A packaged binary run from anywhere else offers to install itself by running the script it carries, with `PINGGY_BINARY_URL` and `PINGGY_INSTALL_ONLY=1` (`src/install/selfInstall.ts`). It finds the copy `pinggy` runs in `src/install/pinggyOnPath.ts`, so a change to how either script tells an npm copy changes that file in the same commit. `pinggy autostart on` writes the boot entry only from the path the scripts install to (`installerBinaryPath()` in `src/daemon/lifecycle/serviceInstaller.ts`), so changing either script's install directory changes that function in the same commit. Once the device connects, both scripts offer `pinggy autostart on` unless the boot entry exists. A script run with `PINGGY_VERSION` set to a release before `pinggy autostart` fails that question, and the install still succeeds. They look for the task name, plist or unit file that `serviceInstaller.ts` writes, and the installed binary's path in it, so renaming any of them changes both scripts in the same commit. Before the sign-in, both scripts offer to restart a daemon that runs another version (ARCHITECTURE.md section 17, "Install scripts."). They read `pid`, `host` and `cliVersion` from `daemon.json`, look for `--_daemon-child` in the daemon's command line, and `install.sh` restarts through the launchd label or the systemd unit as `serviceRestartInstruction()` does. Renaming any of those fields, the flag, the label or the unit changes both scripts in the same commit.
|
|
87
87
|
|
|
88
88
|
Section 17 of `ARCHITECTURE.md` has the protocol, the retry and terminal outcome table, the `device.json` rules, and the full composition table. The design docs are in the `pinggy_backend` repo under `docs/pinggy-devices/`; read `cli.md` there before changing anything in `src/devices/`.
|
|
89
89
|
|
|
@@ -98,9 +98,10 @@ Section 17 of `ARCHITECTURE.md` has the protocol, the retry and terminal outcome
|
|
|
98
98
|
| `pinggy stop <name\|id>` | Stop running tunnel(s) by name or ID prefix |
|
|
99
99
|
| `pinggy ps` | Table of running tunnels (ID, name, status, local, URL) |
|
|
100
100
|
| `pinggy attach <name\|id>` | Re-attach TUI to a running tunnel |
|
|
101
|
-
| `pinggy daemon start \| stop \| status
|
|
101
|
+
| `pinggy daemon start \| stop \| status` (alias `d`) | Daemon lifecycle. `service-install` and `service-uninstall` print their `pinggy autostart` replacement and exit 1 |
|
|
102
102
|
| `pinggy update [--check \| --rollback]` | Update to the latest release now, print the latest version and change nothing, or go back to the previous version. A background check starts on its own; `PINGGY_AUTO_UPDATE=false` turns it off |
|
|
103
|
-
| `pinggy device login \| connect \| start [--foreground] [--files on\|off] \| stop \| status \| remove [-f]` | Sign this machine in by email, or enrol it with a token, as a Pinggy device (`start` is the same as `connect`); the agent runs in the daemon, or in this terminal with `--foreground`, and `stop` stops the daemon's; `--files` answers the file access question, which a terminal run otherwise asks once; show whether the agent runs, the enrolment and the background agent; show the device and its connection, ask, then stop every agent and forget the credential (`-f` skips the question) |
|
|
103
|
+
| `pinggy device login \| connect \| start [--foreground] [--files on\|off] \| stop \| status \| remove [-f]` | Sign this machine in by email, or enrol it with a token, as a Pinggy device (`start` is the same as `connect`); the agent runs in the daemon, or in this terminal with `--foreground`, and `stop` stops the daemon's; `--files` answers the file access question, which a terminal run otherwise asks once; show whether the agent runs, the enrolment and the background agent; show the device and its connection, ask, then stop every agent and forget the credential and the boot entry (`-f` skips the question) |
|
|
104
|
+
| `pinggy autostart [on \| off \| status]` | Bring this device online each time this computer starts. `on` writes the boot entry (systemd unit, launchd plist, Windows task), and first asks to start the agent when `daemon-config.json` saves none. `off` removes the boot entry and leaves the running agent alone. No word means `status` |
|
|
104
105
|
|
|
105
106
|
### Auto-update
|
|
106
107
|
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Create secure, shareable tunnels to your localhost and manage them from the comm
|
|
|
12
12
|
- Foreground (live TUI) and detached (`-b`) tunnel modes
|
|
13
13
|
- Lifecycle commands: `ps`, `start`, `stop`, `restart`, `attach`
|
|
14
14
|
- Per-tunnel and per-daemon log files with `pinggy logs` (tail, follow, rotation-safe)
|
|
15
|
-
-
|
|
15
|
+
- Device autostart with `pinggy autostart on` (systemd, launchd, Task Scheduler)
|
|
16
16
|
- Remote management via secure WebSocket connection (works with Pinggy Dashboard)
|
|
17
17
|
- Pinggy Devices: enrol the machine with `pinggy device` and keep it visible in the dashboard
|
|
18
18
|
- Save and load configuration files
|
|
@@ -299,7 +299,23 @@ Then it prints the device id, server, masked token, and enrolment time from the
|
|
|
299
299
|
pinggy device remove
|
|
300
300
|
```
|
|
301
301
|
|
|
302
|
-
Prints the device id and whether the device is connected now, in the background or with `--foreground` in another terminal, then asks "Remove this device from this machine? [y/N]". Only `y` removes it: the command stops the device agent, then deletes the local credential. With no terminal, it refuses unless you add `-f`, which removes without asking. The device still exists in the dashboard. Delete it there to revoke it, because a machine that has lost its credential cannot authenticate the delete.
|
|
302
|
+
Prints the device id and whether the device is connected now, in the background or with `--foreground` in another terminal, then asks "Remove this device from this machine? [y/N]". Only `y` removes it: the command stops the device agent, then deletes the local credential. With no terminal, it refuses unless you add `-f`, which removes without asking. The device still exists in the dashboard. Delete it there to revoke it, because a machine that has lost its credential cannot authenticate the delete. When autostart is on, remove turns it off too.
|
|
303
|
+
|
|
304
|
+
### Start on boot
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
pinggy autostart on # Bring this device online each time this computer starts
|
|
308
|
+
pinggy autostart off # Stop that. The device stays online until the next restart
|
|
309
|
+
pinggy autostart status # Show whether it is on. `pinggy autostart` alone does the same
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
`on` writes a boot entry that starts the daemon: a systemd user service on Linux, a launchd agent on macOS, a Task Scheduler task on Windows. On Linux it also turns on lingering, so the device comes online at boot with nobody signed in. On macOS and Windows it comes online when you sign in. Only the copy the Pinggy installer put in place may write the entry, so the npm version and a downloaded binary are refused with the command to run instead.
|
|
313
|
+
|
|
314
|
+
A restart brings the device back only when the daemon also runs its agent, which `login`, `connect` and `start` set up and `--foreground` does not. So `on` checks that first. With no background agent, it asks "Start it now, and each time this computer starts? [Y/n]" before it starts one. With no terminal it asks nothing and names `pinggy device start`. On a machine that is not signed in, it refuses and names `pinggy device login`.
|
|
315
|
+
|
|
316
|
+
`off` removes the boot entry and stops nothing, so it is safe to run from the dashboard's browser terminal. To take the device offline now, run `pinggy device stop`.
|
|
317
|
+
|
|
318
|
+
`pinggy daemon service-install` and `pinggy daemon service-uninstall` were the old names. They now print the new command and exit 1.
|
|
303
319
|
|
|
304
320
|
### Reconnect and stop conditions
|
|
305
321
|
|
|
@@ -339,11 +355,11 @@ It enrols, learns its device id and heartbeat interval from the dashboard, and s
|
|
|
339
355
|
|
|
340
356
|
### Devices, tunnels, and the daemon
|
|
341
357
|
|
|
342
|
-
- By default the daemon runs the agent. `pinggy device connect` and `login` start a daemon when none runs. `pinggy daemon stop` stops the agent with every tunnel, and so does a reboot. Every daemon start runs it again, until `pinggy device remove`. `pinggy device stop` stops it until the daemon starts again. With `pinggy
|
|
358
|
+
- By default the daemon runs the agent. `pinggy device connect` and `login` start a daemon when none runs. `pinggy daemon stop` stops the agent with every tunnel, and so does a reboot. Every daemon start runs it again, until `pinggy device remove`. `pinggy device stop` stops it until the daemon starts again. With `pinggy autostart on`, the daemon starts with the computer, so the device comes back online after a reboot. `pinggy device start` or `pinggy device connect` starts it again after a stop.
|
|
343
359
|
- With `--foreground` the agent is its own process. It never starts the daemon, `pinggy daemon stop` leaves it running, and Ctrl+C on it leaves every tunnel running.
|
|
344
360
|
- 1 enrolment per machine. The newest successful connect overwrites `device.json`, and a `--token` on the command line beats the stored one.
|
|
345
361
|
- 1 agent per machine. `connect` and `login` refuse while another terminal runs a `--foreground` agent. `--foreground` is refused while the daemon runs an agent. Stop that one first with `pinggy device stop`.
|
|
346
|
-
- `pinggy device remove` stops a running agent, in the background or with `--foreground` in another terminal, before it deletes the credential file.
|
|
362
|
+
- `pinggy device remove` stops a running agent, in the background or with `--foreground` in another terminal, before it deletes the credential file. Then it removes the boot entry, when there is one.
|
|
347
363
|
|
|
348
364
|
|
|
349
365
|
## Usage
|