From 6dfae0c390ca2a0dc3d6dabc1a52263bfec9b6a7 Mon Sep 17 00:00:00 2001 From: yyamashita Date: Sat, 16 May 2026 12:26:09 +0900 Subject: Add Claude Code daemon setup for remote sessions per repo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit systemd サービス (claude-infra/tokyo/whoisband) を生成・有効化するセットアップスクリプトを追加。 claude remote-control で各リポジトリの常駐セッションを起動し、claude.ai/code から接続できる。 Co-Authored-By: Claude Sonnet 4.6 --- Deploy.md | 25 ++++++++++++++++++++ scripts/claude-daemon-setup.sh | 52 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 scripts/claude-daemon-setup.sh diff --git a/Deploy.md b/Deploy.md index 0ba98a2..2a50159 100644 --- a/Deploy.md +++ b/Deploy.md @@ -60,6 +60,31 @@ ssh golive 'docker logs whois-app -f' 4. `git remote add hetzner golive:/var/git/.git` 5. `git push hetzner master` +## Claude Code リモートセッション(デーモン) + +各リポジトリに対して Claude Code を常駐プロセスとして起動する。 + +```bash +scp scripts/claude-daemon-setup.sh golive:~/ +ssh golive 'bash claude-daemon-setup.sh' +``` + +起動後は [https://claude.ai/code](https://claude.ai/code) から各リポジトリのセッションに接続できる。 + +| サービス名 | 対象ディレクトリ | +|---|---| +| `claude-infra` | `/app/infra` | +| `claude-tokyo` | `/app` | +| `claude-whoisband` | `/app/whois-band` | + +```bash +# 状態確認 +ssh golive 'systemctl status claude-tokyo' + +# ログ確認 +ssh golive 'journalctl -u claude-tokyo -f' +``` + ## 初回サーバーセットアップ(再構築時) ```bash diff --git a/scripts/claude-daemon-setup.sh b/scripts/claude-daemon-setup.sh new file mode 100644 index 0000000..35f5416 --- /dev/null +++ b/scripts/claude-daemon-setup.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# Set up Claude Code remote-control daemons for each app repo (run as root on Hetzner VPS). +set -e + +# Install Claude Code if not present +if ! command -v claude &>/dev/null; then + npm install -g @anthropic-ai/claude-code +fi + +declare -A REPOS=( + ["infra"]="/app/infra" + ["tokyo"]="/app" + ["whoisband"]="/app/whois-band" +) + +for NAME in "${!REPOS[@]}"; do + DIR="${REPOS[$NAME]}" + SERVICE="claude-${NAME}.service" + + cat > "/etc/systemd/system/${SERVICE}" << EOF +[Unit] +Description=Claude Code Remote Session - ${NAME} +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=${DIR} +ExecStart=/usr/bin/env claude remote-control --name "${NAME}" --spawn worktree +Restart=always +RestartSec=15 +StandardOutput=journal +StandardError=journal + +[Install] +WantedBy=multi-user.target +EOF + + systemctl daemon-reload + systemctl enable "${SERVICE}" + systemctl restart "${SERVICE}" + echo "Started: ${SERVICE} (WorkingDirectory: ${DIR})" +done + +echo "" +echo "All Claude Code daemons running. Connect via https://claude.ai/code" +echo "" +echo "Useful commands:" +echo " systemctl status claude-infra" +echo " systemctl status claude-tokyo" +echo " systemctl status claude-whoisband" +echo " journalctl -u claude-tokyo -f" -- cgit v1.2.3