diff options
| author | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-05-17 11:02:19 +0900 |
|---|---|---|
| committer | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-05-17 11:02:42 +0900 |
| commit | b836174d5ad5e4ea36a5f456061a00862317375f (patch) | |
| tree | 96dab7747ccf0ca42b2f408f1fc74e34bf41fe0e /Deploy.md | |
| parent | e3ac39aeeb17ae97949b2e69969f1ce8a364b343 (diff) | |
Add Claude Code session management via post-receive hook
Root's post-receive hook now calls scripts/sync-claude-services.sh to
manage yyamashita's systemd user services on git push. Sessions are
configured in claude-code-sessions.txt (user:repo format).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'Deploy.md')
| -rw-r--r-- | Deploy.md | 40 |
1 files changed, 24 insertions, 16 deletions
@@ -60,29 +60,37 @@ ssh golive 'docker logs whois-app -f' 4. `git remote add hetzner golive:/var/git/<name>.git` 5. `git push hetzner master` -## Claude Code リモートセッション(デーモン) +## Claude Code セッション管理 -各リポジトリに対して Claude Code を常駐プロセスとして起動する。 +`git push` 時に post-receive フック(root)が `yyamashita` ユーザーの systemd user service を自動同期する。 -```bash -scp scripts/claude-daemon-setup.sh golive:~/ -ssh golive 'bash claude-daemon-setup.sh' -``` +| ファイル | 役割 | +|---|---| +| `systemd/user/claude-code@.service` | サービステンプレート | +| `claude-code-sessions.txt` | 有効にするセッション一覧(`user:repo` 形式) | +| `scripts/sync-claude-services.sh` | root が user service を同期するスクリプト | -起動後は [https://claude.ai/code](https://claude.ai/code) から各リポジトリのセッションに接続できる。 +### セッション追加・削除 -| サービス名 | 対象ディレクトリ | -|---|---| -| `claude-infra` | `/app/infra` | -| `claude-tokyo` | `/app` | -| `claude-whoisband` | `/app/whois-band` | +`claude-code-sessions.txt` を編集して `git push hetzner master`: + +``` +# 形式: user:repo +yyamashita:hetzner-infra +yyamashita:new-repo +``` + +### 手動同期(サーバー上で) ```bash -# 状態確認 -ssh golive 'systemctl status claude-tokyo' +ssh root@localhost 'bash /app/infra/scripts/sync-claude-services.sh' +``` -# ログ確認 -ssh golive 'journalctl -u claude-tokyo -f' +### サービス確認 + +```bash +systemctl --user status 'claude-code@*.service' +tmux ls ``` ## 初回サーバーセットアップ(再構築時) |
