feat: native launchd daemon support for macOS#16
Merged
Conversation
Docker Desktop の VM/自動更新起因の停止(2026-07-06〜07 実障害)を回避するため、 macOS では calsync バイナリを launchd の LaunchAgent として直接常駐できるように した。Go コードの変更はゼロで、追加は plist テンプレートとインストール/アンイ ンストールスクリプト、ドキュメントのみ。Linux / Docker 運用は変更なし。
There was a problem hiding this comment.
Pull request overview
macOS で Docker Desktop を介さずに launchd の LaunchAgent として calsync を常駐させるための、インストール/アンインストール用スクリプトと関連ドキュメントを追加する PR です(Go コードは変更なしで、Linux/Docker 運用も維持)。
Changes:
- macOS 向けに
launchdの LaunchAgent を生成・登録・起動/解除するスクリプトと plist テンプレートを追加 - README / スキル / 設計書 / AGENTS / CHANGELOG を更新し、ネイティブ常駐の運用手順と注意点を明文化
- 移行時の落とし穴(
credentials_file: /data/...)や bootout→bootstrap の EIO を考慮した冪等フローを整備
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/macos/install-launchd.sh | ビルド→plist 生成→bootout/bootstrap/kickstart までの冪等インストール処理を追加 |
| scripts/macos/uninstall-launchd.sh | LaunchAgent の解除と plist 削除のみ行う冪等アンインストーラを追加 |
| scripts/macos/com.btajp.calsync.plist.template | ProgramArguments / KeepAlive / ThrottleInterval / (任意)EnvironmentVariables を持つ plist テンプレートを追加 |
| README.md | macOS は launchd ネイティブ常駐を推奨する運用手順を追記 |
| docs/superpowers/specs/2026-07-07-macos-launchd-design.md | macOS launchd 対応の設計書を追加 |
| CHANGELOG.md | macOS launchd 常駐サポート追加を Added に追記 |
| AGENTS.md | 「SQLite へ触るな」の注意をコンテナ運用限定である旨に更新 |
| .agents/skills/calsync-setup/SKILL.md | OS 別(macOS: launchd / その他: compose)の常駐手順に分岐するよう更新 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - ラベル: `com.btajp.calsync`。配置先: `~/Library/LaunchAgents/com.btajp.calsync.plist`(**chmod 600** — トークンを含むため) | ||
| - `ProgramArguments`: `<BIN>/calsync run --config <DATA>/calsync.yaml --data <DATA>`(すべて絶対パス) | ||
| - `RunAtLoad: true` + `KeepAlive: true` — ログイン時自動起動+クラッシュ自動再起動(`restart: unless-stopped` 相当) | ||
| - `EnvironmentVariables`: `SLACK_TOKEN_CALSYNC`(または `bot_token_env` で指定した名前)を**plist に直接埋め込む**。launchd の LaunchAgent はシェルプロファイルを読まないため env はここで渡すしかない。ファイルは 600 で保護し、インストールスクリプトが現在のシェル環境変数から値を転記する |
Comment on lines
+34
to
+37
| if ! command -v python3 >/dev/null 2>&1; then | ||
| die "python3 が見つかりません。Xcode Command Line Tools をインストールしてください(xcode-select --install)" | ||
| fi | ||
|
|
Comment on lines
+109
to
+111
| mkdir -p "$(dirname "${LOG_FILE}")" | ||
| touch "${LOG_FILE}" | ||
|
|
Comment on lines
+137
to
+141
| start_marker = "<!-- ENVIRONMENT_VARIABLES_START -->" | ||
| end_marker = "<!-- ENVIRONMENT_VARIABLES_END -->" | ||
| start = content.index(start_marker) | ||
| end = content.index(end_marker) + len(end_marker) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
macOS で Docker Desktop を経由せず、calsync を launchd の LaunchAgent としてネイティブ常駐できるようにします。Linux / その他の Docker compose 運用は無変更(Go コードの変更もゼロ)。
動機
2026-07-06〜07 の実障害: Docker Desktop の自動アップデートで仮想ネットワークが壊れ、calsync が 16 時間無言停止。calsync は純 Go・CGO なし・単一静的バイナリのため、macOS ではコンテナの利点がほぼなく、VM 境界(仮想 NW・VirtioFS)が障害源にしかなっていなかった。ネイティブ化で以下を根本解消:
status/doctorも安全に)内容
scripts/macos/install-launchd.sh— ビルド → plist 生成(600・トークンは XML エスケープして埋め込み)→ bootout 完了待ち → bootstrap(リトライ付き)→ kickstart -k まで冪等scripts/macos/uninstall-launchd.sh/com.btajp.calsync.plist.template(RunAtLoad + KeepAlive + ThrottleInterval 10)実機検証済み(この Mac で本番移行済み)
kickstart -kの再起動 ✅credentials_file: /data/...のままだとクラッシュループ → 事前検知エラー+README 明記検証
bash -n/ shellcheck(0 findings)/go build/go test ./... -race -count=1/go vet/gofmt(Go 差分ゼロの確認を兼ねる)✅