Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

autostream-worker

AutoStream の Worker service です。

役割

  • Control Panel から stream job context を受け取ります。
  • overlay、caption、participant、active-speaker、current-time event から16:9の配信映像を描画します。
  • Discord Bot の Discord Opus packet を受け取り、Deepgram のリアルタイム字幕を生成します。
  • 描画した映像をjob-scoped暗号化SRTで選択済みEncoder/Recorderへ送り、診断用eventも転送します。
  • Control Panel へ heartbeat と signal を送信し、Control Panel 経由で Observability に反映します。

主な環境変数

AUTOSTREAM_NODE_CONFIG=/etc/autostream-worker/config.yml
AUTOSTREAM_ENV=production
AUTOSTREAM_REQUIRE_CONTROL_PANEL_RUNTIME_CONFIG=true
AUTOSTREAM_SCENE_FONT_FILE=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
TZ=Asia/Tokyo

Worker generates the 16:9 program scene as low-rate JPEG images and sends those images to the assigned Encoder/Recorder. Worker does not encode video or mux audio; Encoder/Recorder retains the latest image and performs the final configured-FPS CBR video encode, audio mux, preview, recording, and delivery. The Worker host therefore requires a Japanese Noto font but does not require FFmpeg. AUTOSTREAM_SCENE_FONT_FILE is an optional absolute-path override. When it is unset, Worker uses the exact path /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc so existing worker.env files keep the same font selection. If the selected file is missing or invalid, startup fails closed; Worker never falls back to a non-Japanese basic font. On Debian/Ubuntu, install fontconfig and fonts-noto-cjk.

Panel-managed config.yml must select listener.credential: node-listener.json. For systemd, LoadCredential exposes the strict four-field JSON from /opt/autostream/local-executor/ports/worker.json; its bind_address is the only local listener authority and its positive config_revision is reported by /updater/version. The JSON also carries schema_version: 2 and service_type: worker. Missing, malformed, writable, or mismatched credentials fail closed. There is no bind or revision environment fallback.

api.host and api.port remain the public/reverse-proxy endpoint and do not select the local socket. The listener bind_address must use an unprivileged port from 1024 through 65535; the standard host value is 127.0.0.1:8084. 例えば 127.0.0.1:18084 に変更した場合、/health と /updater/version も同じ 18084 で待ち受けます。不正な形式、範囲外、 または特権ポートを指定した場合は Worker が起動時に安全側で停止します。 IPv6 loopback を明示的に使う場合は [::1]:18084 のように角括弧を含めて 指定し、プローブURLも http://[::1]:18084/... とします。

Docker 版のホスト公開ポートは Compose 実行時の AUTOSTREAM_WORKER_PORT で変更できます。コンテナ内ポートも変更する場合は AUTOSTREAM_WORKER_CONTAINER_PORT を併せて指定します。どちらも 1024~65535 を使用してください。

Compose published ports are a host/reverse-proxy responsibility. The Control Panel Updater manages only host ports 1024 through 65535; manually publishing a privileged or conflicting Docker host port is outside the managed update contract.

The production health authority is the host Local Executor. These Compose files intentionally omit an in-container healthcheck: the runtime image has no purpose-built HTTP probe client, and the image contract does not add or repurpose curl, wget, or another unrelated executable solely for container health. For managed Docker changes, the Local Executor probes the loopback published port for both /health and /updater/version; the published port is the health port. A recreate is accepted only when health, service identity, version, and the listener credential's config_revision match; otherwise the executor rolls back or reports rollback_failed.

$env:AUTOSTREAM_WORKER_PORT = "18084"
$env:AUTOSTREAM_CONFIG_REVISION = "1" # Compose JSON generation input only
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d

AUTOSTREAM_NODE_CONFIG には Control Panel の Node登録で生成した config.yml を指定します。Node Runtime Token、service identity、public endpoint、listener credential selector、stream-scoped token の検証に使う stream_ingest.signing_key はこのファイルから読み込みます。WorkerのsignalsはControl Panelのtyped Observability経路へ送信します。

Encoder/Recorder のevent送信先とworker-event tokenはControl Panelのstream job contextで encoder_recorder_url / stream_ingest_token として渡されます。映像用のSRT URL・passphrase・key lengthも同じstart処理内で一度だけ渡され、URLやargv、log、statusへ秘密を埋め込みません。

AUTOSTREAM_REQUIRE_CONTROL_PANEL_RUNTIME_CONFIG=true または AUTOSTREAM_ENV=production の場合、Worker は Control Panel registration と runtime config 取得に失敗すると起動を停止します。runtime config に含まれる自 service の primary assignment だけを受け付け、standby または別 Worker に割り当てられた stream の /jobs/start は拒否します。

字幕は stream job context の caption_profile_id が選択されている場合だけ有効です。Worker は対応する runtime-config の caption profile を厳密に選び、job start 時に Node Runtime Token と対象 stream_id で Control Panel の /services/runtime-secrets/resolve を一度だけ呼び出して deepgram_api_key を取得します。DEEPGRAM_API_KEY などの環境変数fallbackはありません。profile 未選択時の POST /streams/{id}/audio/opus は 409、secret取得失敗時の /jobs/start は 503 で失敗します。

Deepgram 接続先は wss://api.deepgram.com/v1/listen 固定です。Discord Opus は SSRC / speaker ごとの接続へ binary frame で転送し、interim result は caption.telop、final result は caption.final として Encoder/Recorder へ送信します。

開発

go test ./...
go build ./...

Security

  • Node Runtime Token、Encoder token、Observability token を log / API response に出しません。
  • Discord Bot には Worker の Node Runtime Token を渡さず、用途別の stream-scoped worker_events / caption_audio token だけを受け付けます。
  • Discord音声endpointは stream-scoped caption_audio tokenを受け付け、service_type=discord_bot、audience=worker、stream_id を検証します。
  • Deepgram API key は browser、Discord Bot、log、API response、URL queryへ出しません。
  • Encoder/Recorder への token-bearing request は redirect と unsafe HTTP を安全側で拒否します。
  • event payload に secret-like value を入れないでください。

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages