Files
Piik/docs/deployment.md
AAAandPedro Antonio c18502fd18 feat: improve microphone, chat and platform support
This release adds microphone processing controls and local chat controls, expands platform packages, and synchronizes the website and guides. It also fixes native H.264 input/format handling, signaling recovery, fresh STUN discovery, and UDP ownership during overlapping connections.

This is **v1.8.0**. Browser/Server v23, Native control v9 and capture v7 remain unchanged, with the existing 1440p ceiling. Additional resolutions, capability negotiation and Magicsock are separate follow-up work.

## Validation

- Full local Web check: 79 files / 1,317 tests, TypeScript and production build.
- Full Go checks, platform builds and Windows native capture regressions/probe.
- Native H.264 Host lifecycle, Browser-to-App fanout and App-exit recovery, and Native H.264 through embedded SFU: all passed with owned process/port/profile cleanup.
- Website build, documentation and repository hygiene passed. Existing UI acceptance covers narrow screens, both languages/themes, architecture downloads and all 23 film checks; final packaging and Go race checks run on the merged revision in CI.
- Physical macOS/Linux capture, representative public networks and unmatched field reports retain their documented evidence limits. No claim that every blur/disconnection report is resolved.

## Release notes

### 中文

这是一次功能与兼容性更新:麦克风和聊天增加了实用的小选项,App 与 Server 支持更多设备,同时修复了原生分享和连接恢复中的若干问题。现有 1.x 协议保持不变。

#### 新增与改进

- 浏览器麦克风新增「降噪与回声消除」开关,默认开启回声消除、降噪和自动增益;分享音乐或使用虚拟音频输入时,可按需关闭。
- 可调整弹幕字号和透明度,并将当前保留的聊天记录导出为 TXT。当前会话最多保留 1,000 条文字消息,刷新页面后清空;需要保存时请先导出。
- 新增 Intel Mac、Linux ARM64 App,以及 Linux ARM64 Server 和容器镜像。官网下载区可直接选择对应架构,并显示最新版本和发布时间。
- 更新官网演示、README 截图和中英文教程,明确浏览器分享也可选择窗口或屏幕;开始分享前显示房间号占位,保持底栏控件位置稳定。
- 官网新增直达问题排查的入口,补充浏览器 WebRTC 限制、校园网和 Windows 显卡相关的排查步骤。
- App 模式选择页显示免费开源说明、作者与贡献者署名,以及官方网站和源码链接。

#### 修复

- 修正部分 H.264 原生分享的格式兼容性校验,以及 Windows 编码器输入长度和输出缓冲区对齐问题。
- 清理已失效的重连任务和 Native 接收信令,避免旧连接继续影响当前会话。
- 修复 App 重连时可能复用过期公网地址的问题;重新探测使用当前地址,并处理探测丢包和过期响应,保留其他正常连接。
- 修复 App 新旧媒体连接重叠时共用端口造成的冲突,避免准备或撤销新连接打断仍在使用的画面;关闭连接时及时取消未完成的端口映射请求。
- 无站点密码时,连接恢复不再误引导用户输入站点密码。
- 房间失效或会话终止时,开播前后的原因提示统一显示在电视状态图标中,避免额外提示条。
- 修正 Linux 原生采集的时间戳与关键帧时间基准。感谢 Pedro Antonio 在 [#449](https://github.com/TNTcraftHIM/Piik/pull/449) 的贡献。

#### 使用说明

下载对应平台的完整压缩包,退出旧 App 后解压使用。Windows 继续提供 x64;macOS 提供 Apple 芯片与 Intel 版本,原生采集需要 macOS 13 或更新版本。Linux 提供 x64 与 ARM64,原生采集还需安装[系统组件](https://github.com/TNTcraftHIM/Piik/blob/main/native/capture/linux/README.md)。macOS 和 Linux 的实机覆盖仍有限,欢迎反馈。

### English

This update adds useful microphone and chat controls, brings Piik to more devices, and fixes several native-sharing and connection-recovery issues. The existing 1.x protocols remain unchanged.

#### New and improved

- Browser microphones now have a “Noise & echo reduction” toggle. Echo cancellation, noise suppression and automatic gain control are on by default; turn them off when appropriate for music or virtual audio inputs.
- Adjust chat-overlay text size and opacity, and export retained messages as TXT. The current session keeps up to 1,000 text messages and clears on page refresh; export first if you want to keep them.
- Added Intel Mac and Linux ARM64 App packages, plus Linux ARM64 Server and container images. The website provides architecture selectors and shows the latest release and publication date.
- Updated the website demonstration, README screenshots and bilingual guides, clarifying that browser capture can also select windows or screens. A room-code placeholder keeps the bottom bar stable before sharing starts.
- Added direct website links to troubleshooting, with steps for browser WebRTC restrictions, campus networks and Windows graphics issues.
- The App mode-selection page now shows its free and open-source status, author and contributor credit, and links to the official website and source.

#### Fixes

- Corrected H.264 format compatibility checks and Windows encoder input-length and output-buffer alignment handling.
- Retired stale reconnect tasks and Native receive signals so they cannot continue affecting the current session.
- Fixed App reconnection reusing an expired public address. Fresh discovery handles lost probes and stale responses while preserving other working connections.
- Fixed UDP socket conflicts between overlapping App media connections so preparing or canceling a replacement preserves the active picture. Closing a connection now cancels unfinished gateway mapping requests.
- Connection recovery on passwordless sites no longer incorrectly asks for a site passphrase.
- Expired-room and session-termination reasons now use the same TV status indicator before and during sharing, without an extra notice strip.
- Corrected Linux native capture timestamps and keyframe time bases. Thanks to Pedro Antonio for [#449](https://github.com/TNTcraftHIM/Piik/pull/449).

#### Updating

Download the complete archive for your platform, quit the old App, and extract the new package. Windows remains x64-only. macOS packages support Apple silicon and Intel; native capture requires macOS 13 or newer. Linux supports x64 and ARM64 and requires additional [system components](https://github.com/TNTcraftHIM/Piik/blob/main/native/capture/linux/README.md) for native capture. Physical-device coverage on macOS and Linux remains limited; feedback is welcome.

## Attribution

Co-authored-by: Pedro Antonio <wrenchwastaken@gmail.com>
2026-10-04 16:21:01 +08:00

12 KiB

Server Release And Recovery

This file owns routine immutable Server releases. Initial service setup is in self-hosting operations; environment and ports are in configuration reference. Exact production identity is owned by the immutable release descriptor, runtime REVISION, and deployment record. Status owns only the compact current product and operational snapshot; it is not a per-release ledger.

The tracked release-server.sh updates an existing Go deployment with embedded media, bare-metal nginx, nftables, and application port 8787. It requires an existing running Go release. Another proxy, firewall owner, application port, first installation, or initial embedded-media cutover needs its own scoped bootstrap/updater; do not call this wrapper generic. Its firewall check compares the nftables ruleset without traffic counters; it does not depend on a particular table name. Coordinate other firewall writers outside the cutover window. See nft output options.

Release Boundary

A routine Server release changes only the built Piik server binary and the Browser assets it embeds. It does not change infrastructure, service units, proxy/firewall rules, secrets, media listener configuration, or persistent room state.

Any task that touches one of those excluded surfaces must first record its exact pre-change value and a recovery procedure for that surface. Do not complicate the routine Server wrapper with one-off infrastructure branches.

The pre-cutover Server release is guaranteed only through bounded health and postflight. It has no retention contract afterward and is not a maintained backup; Git and immutable artifacts own history.

Build Host

Start from a clean exact revision with Node.js 24, npm 11, and Go 1.26:

npm ci
npm run check
node scripts/package-server-release.mjs <output-directory-outside-repository>

The packager refuses a dirty tree, builds the Browser assets and the linux/amd64 server binary (or linux/arm64 with --arch arm64) from that exact revision without cgo, records the full revision, emits a runtime archive plus path/size/SHA-256 manifest and release descriptor, and extracts its own artifact to verify it. The archive contains exactly piik-server, LICENSE, THIRD-PARTY-NOTICES.txt, and REVISION. Upload the archive, manifest, and descriptor together to /opt/piik/uploads. ARM64 file names include -linux-arm64 after the revision; x64 names stay unchanged. The deployment wrapper rejects a package for another host architecture.

Public Release pages expose the runnable packages and put package checksums in the release body. Retain the original complete build output outside the checkout for later managed deployment or mirror retries: descriptors and manifests are available in CI artifacts for 14 days and are not public Release attachments. Do not rebuild an existing published version to replace missing metadata or bytes.

The same Server descriptor is also the App assembly input. On each target platform, provide that platform's Go toolchain:

PIIK_GO=/path/to/go node scripts/assemble-app.mjs \
  /outside/repository/server-release/piik-<revision>.release.json \
  /outside/repository/piik-app \
  --target windows-amd64 \
  --capture /path/to/platform-capture \
  --tunnel /path/to/cloudflared

Assembly refuses a dirty or different revision and emits one directory with the App executable, the Browser assets taken from that release and embedded in it, the selected sidecars, notices, and matching REVISION. Its required target is one of windows-amd64, linux-amd64, linux-arm64, darwin-arm64 or darwin-amd64; every supplied binary input must match it. It does not create an installer, auto-updater, release tag, or compatibility bundle.

Darwin App assembly runs on macOS with its SDK and cgo enabled: the pinned LiveKit dependency's Darwin CPU statistics call Mach APIs. Windows and Linux App builds keep cgo disabled. A core check on those hosts explicitly skips the Darwin binaries; macOS build and package verification belong to the existing native runner. Server builds for both Linux architectures remain cgo-free.

The platform package also carries its native presentation metadata: Windows embeds the icon in the Go executable, Linux emits a freedesktop desktop entry under share/, and macOS emits a thin .app launcher with an ICNS resource. The latter two are packaging metadata only and do not duplicate the App executable.

CI and local release-candidate builds use the same wrapper on the target's native operating system:

node scripts/package-app-candidate.mjs \
  /outside/repository/server-release \
  windows-amd64 \
  /outside/repository/app-candidate

The wrapper downloads the pinned public-link sidecar, verifies its digest, builds the target App and available capture process, executes every packaged runtime from the extracted ZIP, and emits one .zip plus its SHA-256 file.

App ZIPs use ordinary Store/Deflate compression and relative entry names without . or .. path segments; include hidden files and preserve executable modes on Unix. Windows packaging also checks every entry through Windows Explorer's ZIP reader. A successful extraction by the writer's own library does not establish compatibility with the user's default archive tool.

Retain the descriptor and successful deployment output as release metadata. Do not create a follow-up source commit solely to duplicate their revision, asset, or hashes.

Manual app_checks=true dispatch packages both Server architectures and all App candidates after validation. Once automatic publication is explicitly enabled, accepted main merges run that same pipeline and publish the verified artifacts. Candidate artifacts are retained for 14 days. Ordinary branch pushes stay quiet; PRs run only the read-only release-note check. No release-record commit is written back to main. The workflow does not deploy into a running application service.

Do not build or run the full repository check on a constrained production host. That host runs only the packaged binary and needs no Node, npm, or dependency install.

Update Check

Builds carry a product version plus full source revision. Packagers use one release plan or exact Git tag and inject its identity into Server, App and Web; untagged local candidates use development. Schema-2 package descriptors carry the same pair and artifact hashes. The version policy owns ordering and first-public-release readiness.

The default App launcher starts immediately, then checks GitHub Releases in the background, falling back to the Gitee mirror if GitHub is unavailable. The release-source policy owns selection and provenance checks. It shows a link only when the latest stable release is newer, the same version has a known different source SHA, or a development build can choose the official release. These notices are distinct; a different SHA alone is not called newer. The request sends no current revision, credentials, room data, or media data; network errors, private-repository responses, and missing releases are treated as no notice. Checking does not download an archive, replace files, or interrupt a running share; the user can follow the update link to download the App ZIP.

An operator can perform the corresponding read-only Server check:

bash deploy/check-release.sh

The Server also checks once in the background after startup and logs an available release with its download URL. It does not delay startup, periodically poll, notify room participants or install anything.

The script runs the deployed binary's --check-release, using that binary's injected identity, and prints one JSON result with versions, available source SHAs and the release URL. Exit 0 means no newer/different official build, 10 means update-available, different-build or official-release, and 20 means the check is unavailable. It does not accept a separate revision file. For a private repository, inject a short-lived GITHUB_TOKEN through the operator environment; never place it in the repository or command line. The command does not mutate files, services, containers, or persistent state.

Atomic Cutover

The wrapper requires an already running packaged Go release and the service layout described above. For a new installation, use the self-hosting guide. Infrastructure changes need their own scoped recovery procedure under CONTRIBUTING.

Run the tracked server entry with the uploaded descriptor:

sudo env PIIK_PUBLIC_ORIGIN=https://share.example.com \
  bash /path/to/repository/deploy/release-server.sh \
  /opt/piik/uploads/piik-<revision>.release.json

The wrapper:

  1. takes a deployment lock and validates the descriptor, revision, archive, manifest, current Go process, Piik/nginx service state, and public origin;
  2. rejects unexpected archive paths, links, file types, or duplicate inodes;
  3. extracts to a new release directory and verifies every file hash and size;
  4. validates production configuration by running the packaged binary's configuration check as the service user under a bounded runtime;
  5. proves the old and new releases share no regular-file inode;
  6. atomically switches /opt/piik/current, starts the service, and polls bounded local/public health; and
  7. restores the exact prior symlink and service when cutover or health fails.

Never hard-link release files or recursively mutate permissions before the inode audit: metadata changes would violate both releases. Expected service states should be read as data (systemctl show), not used as bare commands under strict-shell error traps.

Persistent State

Stable mode stores only room authority at the configured SQLite path. The systemd service owns its state directory and file permissions. Application restart retains room ownership, invitations, policy and password verifier; participants, signaling, routes, SFU state and media reconnect from fresh process state.

Lightweight mode has no persistent room state and starts empty. A release does not add a migration or compatibility reader for either mode; current exact schema validation fails closed before accepting signaling or media admission.

Postflight

Verify only the surfaces relevant to the release:

  • local and public /healthz return {"status":"ok"};
  • the public HTML references the new immutable main asset;
  • Piik and nginx have expected active/restart state;
  • Piik owns each configured STUN/SFU UDP listener and public reachability matches the configuration;
  • the current symlink and served revision match the descriptor;
  • room creation, Host authentication, one direct Viewer, and configured SFU fallback complete the scoped smoke; and
  • infrastructure, config, secrets, ports, and persistent state not named by the task are unchanged.

Representative network, mobile, audio, 20-Viewer, and endurance evidence belongs to verification status, not routine postflight.

Recovery

Before cutover, the wrapper keeps the exact prior release path. On failure after the switch begins, it stops Piik, restores that path atomically, restarts the service, and waits for health. A failed recovery exits distinctly and requires operator intervention; it must not silently report the new release as active.

Infrastructure or persistent-state recovery is separate and limited to the surfaces changed by that task. Do not restore an entire server, old firewall, or old secret set for an application-only failure.

If a task changes persistent room data, prepare and verify a separate SQLite backup and recover matching data, configuration and application together. Restoring old data can revive revoked credentials; account for later authority changes before reopening ingress.