diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 709c30c..df8eb2f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ # frontend deploy'unun kullandığı üç isim; # * sunucuda `loginctl enable-linger ` (kullanıcı unit'leri için); # * sunucuda podman + bir compose sağlayıcı (deploy ikisini de kontrol eder); -# * operatörün ~/hezarfen_chatbot/hezarfen_chatbot.env (0600) dosyası; +# * operatörün ~/hezarfen_rule_based_chatbot/hezarfen_rule_based_chatbot.env (0600) dosyası; # * BACKEND tarafı açık olmalı: hezarfen_backend.env içinde # AI_QUIC_ADDR=0.0.0.0:8090 ve AI_SHARED_TOKEN bu köprününkiyle AYNI. # (127.0.0.1 yazılıysa backend yalnız kendi loopback'ine bağlanır ve köprü @@ -46,13 +46,13 @@ on: # VPS değişimine dokunmadan bayat Validate/Build'i iptal edebilmeli. env: - # systemd kullanıcı unit'i. Bkz. deploy/hezarfen_chatbot_compose.service. - SERVICE: hezarfen_chatbot_compose + # systemd kullanıcı unit'i. Bkz. deploy/hezarfen_rule_based_chatbot_compose.service. + SERVICE: hezarfen_rule_based_chatbot_compose # Deploy, SSH kullanıcısının home'u altındaki bu alt dizinde yaşar ($HOME # sunucuda çözülür, yani kullanıcı değişince yol da onunla gelir). - DEPLOY_SUBDIR: hezarfen_chatbot + DEPLOY_SUBDIR: hezarfen_rule_based_chatbot # Köprünün ayar dosyası; deploy yalnız varlığını kontrol eder, yazmaz. - ENV_FILE_NAME: hezarfen_chatbot.env + ENV_FILE_NAME: hezarfen_rule_based_chatbot.env # Sağlık kapısı: backend'in verdiği kayıt onayı logda bu satırdır. READY_MARKER: "kayıt başarılı" # Köprünün backend sertifikasını çektiği yol (HTTP, backend konteynerinin portu). @@ -111,20 +111,20 @@ jobs: - name: Build the image run: | set -euo pipefail - docker build -f Containerfile -t localhost/hezarfen_chatbot:$GITHUB_SHA . + docker build -f Containerfile -t localhost/hezarfen_rule_based_chatbot:$GITHUB_SHA . - name: Stage the release bundle run: | set -euo pipefail mkdir -p stage - docker save localhost/hezarfen_chatbot:$GITHUB_SHA | gzip > stage/hezarfen_chatbot.tar.gz - cp compose.yaml deploy/hezarfen_chatbot_compose.service stage/ + docker save localhost/hezarfen_rule_based_chatbot:$GITHUB_SHA | gzip > stage/hezarfen_rule_based_chatbot.tar.gz + cp compose.yaml deploy/hezarfen_rule_based_chatbot_compose.service stage/ echo -n "$GITHUB_SHA" > stage/tag # Sunucuda kurulacak her şey burada olmalı; eksik parça burada, # sunucuda değil, patlar. - test -f stage/hezarfen_chatbot.tar.gz + test -f stage/hezarfen_rule_based_chatbot.tar.gz test -f stage/compose.yaml - test -f stage/hezarfen_chatbot_compose.service + test -f stage/hezarfen_rule_based_chatbot_compose.service test -f stage/tag ls -l stage @@ -199,9 +199,9 @@ jobs: - name: Check the release is complete run: | set -euo pipefail - test -f stage/hezarfen_chatbot.tar.gz + test -f stage/hezarfen_rule_based_chatbot.tar.gz test -f stage/compose.yaml - test -f stage/hezarfen_chatbot_compose.service + test -f stage/hezarfen_rule_based_chatbot_compose.service test -f stage/tag - name: Install SSH keys @@ -227,14 +227,14 @@ jobs: ;; esac deploy_path=$HOME/$1 - # Bu dizin operatörün hezarfen_chatbot.env dosyasını, compose + # Bu dizin operatörün hezarfen_rule_based_chatbot.env dosyasını, compose # dosyalarını ve tag dosyalarını tutar; hiçbiri toptan silinmez. mkdir -p -- "$deploy_path" REMOTE # stdin paketi taşıyor, betik taşıyamaz; çıkarma yine bash -c ile # çünkü login shell bash değil ve $HOME'u genişletmez. Sunucuya # yalnız dört deploy dosyası kurulur. - tar -C stage -czf - hezarfen_chatbot.tar.gz compose.yaml hezarfen_chatbot_compose.service tag | ssh "$ssh_target" "bash -c 'exec tar -xzf - -C \"\$HOME/\$1\"' -- '$DEPLOY_SUBDIR'" + tar -C stage -czf - hezarfen_rule_based_chatbot.tar.gz compose.yaml hezarfen_rule_based_chatbot_compose.service tag | ssh "$ssh_target" "bash -c 'exec tar -xzf - -C \"\$HOME/\$1\"' -- '$DEPLOY_SUBDIR'" - name: Load the image and restart the bridge run: | @@ -258,10 +258,10 @@ jobs: # Hiçbir şey oynamadan önce oku: ayar dosyası operatörün, sunucuda, # elle bir kez yazılır (anahtarlar için bkz. - # deploy/hezarfen_chatbot.env.example). Deploy onu asla oluşturmaz, + # deploy/hezarfen_rule_based_chatbot.env.example). Deploy onu asla oluşturmaz, # ezmez. if [ ! -f "$env_file" ]; then - echo "missing $env_file — create it (0600) from deploy/hezarfen_chatbot.env.example" >&2 + echo "missing $env_file — create it (0600) from deploy/hezarfen_rule_based_chatbot.env.example" >&2 exit 1 fi chmod 0600 -- "$env_file" @@ -290,7 +290,7 @@ jobs: # BU build'in imajını yükle ve build'in damgaladığı tag'i oku # (build zamanı ile deploy zamanı neyin gittiğinde anlaşmalı). - gunzip -c "$deploy_path/hezarfen_chatbot.tar.gz" | podman load + gunzip -c "$deploy_path/hezarfen_rule_based_chatbot.tar.gz" | podman load tag=$(cat -- "$deploy_path/tag") # Tag rotasyonu: previous_tag geri dönüş hedefidir (ilk deploy'da @@ -305,9 +305,9 @@ jobs: # kazanan yapar. printf 'HEZARFEN_TAG=%s\n' "$tag" > "$deploy_path/stack.env" - chmod 0644 -- "$deploy_path/compose.yaml" "$deploy_path/hezarfen_chatbot_compose.service" + chmod 0644 -- "$deploy_path/compose.yaml" "$deploy_path/hezarfen_rule_based_chatbot_compose.service" # İmaj tarball'ı yalnız taşıyıcıydı; imaj artık podman deposunda. - rm -f -- "$deploy_path/hezarfen_chatbot.tar.gz" + rm -f -- "$deploy_path/hezarfen_rule_based_chatbot.tar.gz" compose_up() { podman compose --env-file "$env_file" --env-file "$deploy_path/stack.env" up -d --no-build @@ -330,7 +330,7 @@ jobs: # Unit sürümle birlikte gelir: yeni kurulmuş bir kutuda ilk deploy'a # kadar unit yoktur ve değişen unit onu gerektiren compose ile iner. mkdir -p -- "$HOME/.config/systemd/user" - install -m 0644 -- "$deploy_path/hezarfen_chatbot_compose.service" "$HOME/.config/systemd/user/$service.service" + install -m 0644 -- "$deploy_path/hezarfen_rule_based_chatbot_compose.service" "$HOME/.config/systemd/user/$service.service" systemctl --user daemon-reload # Unit RemainAfterExit'li bir oneshot: aktif (exited) unit'te `start` @@ -346,7 +346,7 @@ jobs: # yeniden bağlanma aralıkları zaman alır. ready_ok=0 for _ in $(seq 1 60); do - if podman logs --tail 200 hezarfen_chatbot 2>&1 | grep -q "$ready_marker"; then + if podman logs --tail 200 hezarfen_rule_based_chatbot 2>&1 | grep -q "$ready_marker"; then ready_ok=1 break fi @@ -354,14 +354,14 @@ jobs: done if [ "$ready_ok" -ne 1 ]; then echo "the bridge never registered with the backend ('$ready_marker' missing); rolling back" >&2 - podman logs --tail 30 hezarfen_chatbot 2>&1 >&2 || true + podman logs --tail 30 hezarfen_rule_based_chatbot 2>&1 >&2 || true rollback exit 1 fi # Eski bir stack de cevap verebilir; çalışan konteyner BU build'in # imajı olmalı, yoksa geri dönülür. - image=$(podman inspect -f '{{.Config.Image}}' hezarfen_chatbot) + image=$(podman inspect -f '{{.Config.Image}}' hezarfen_rule_based_chatbot) case "$image" in *"$tag"*) ;; *) @@ -370,7 +370,7 @@ jobs: exit 1 ;; esac - echo 'hezarfen_chatbot_compose is up' + echo 'hezarfen_rule_based_chatbot_compose is up' REMOTE # Bağımsız son kontrol: cevap veren konteyner hâlâ güncel tag'in olmalı ve @@ -386,7 +386,7 @@ jobs: export XDG_RUNTIME_DIR=/run/user/$(id -u) cd -- "$deploy_path" tag=$(cat -- "$deploy_path/current_tag") - image=$(podman inspect -f '{{.Config.Image}}' hezarfen_chatbot) + image=$(podman inspect -f '{{.Config.Image}}' hezarfen_rule_based_chatbot) case "$image" in *"$tag"*) ;; *) @@ -394,9 +394,9 @@ jobs: exit 1 ;; esac - status=$(podman inspect -f '{{.State.Status}}' hezarfen_chatbot) + status=$(podman inspect -f '{{.State.Status}}' hezarfen_rule_based_chatbot) [ "$status" = "running" ] || { echo "container status is '$status', not running" >&2; exit 1; } - podman logs --tail 200 hezarfen_chatbot 2>&1 | grep -q "$ready_marker" || { + podman logs --tail 200 hezarfen_rule_based_chatbot 2>&1 | grep -q "$ready_marker" || { echo "the bridge is not registered with the backend" >&2 exit 1 } diff --git a/.gitignore b/.gitignore index 2234149..fbeb69b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,10 +23,10 @@ data/stress_benchmark_results.jsonl # Okunabilir Markdown raporu repoda tutulur; ham JSON tutulmaz. data/benchmark_results.json -# Compose/sistem ortam dosyaları: operatörün ayarları (hezarfen_chatbot.env) ve +# Compose/sistem ortam dosyaları: operatörün ayarları (hezarfen_rule_based_chatbot.env) ve # deploy sahipli tag taşıyıcısı (stack.env) makineye özeldir, git'e girmez. -# Şablon: deploy/hezarfen_chatbot.env.example -hezarfen_chatbot.env +# Şablon: deploy/hezarfen_rule_based_chatbot.env.example +hezarfen_rule_based_chatbot.env stack.env # CI deploy paketi (imaj tarball'ı + compose dosyaları + tag). diff --git a/Containerfile b/Containerfile index 6373be8..f3558c7 100644 --- a/Containerfile +++ b/Containerfile @@ -20,15 +20,15 @@ RUN useradd --create-home --uid 10001 chatbot \ USER chatbot # Dağıtım varsayılanları — TEK yazıldıkları yer. Sunucu bunları -# hezarfen_chatbot.env (env_file) ile ezer; compose dosyası hiçbir anahtar +# hezarfen_rule_based_chatbot.env (env_file) ile ezer; compose dosyası hiçbir anahtar # listelemez, böylece operatörün dosyası gölgelenemez. # # AI_BACKEND_URL köprünün sertifikayı çektiği HTTP kökü: backend konteynerinin # kendi portu (compose'da PORT=7656). Sertifika her (yeniden) bağlanmada # tazelenir. -ENV AI_BRIDGE_HOST=hezarfen-backend \ +ENV AI_BRIDGE_HOST=hezarfen_backend \ AI_BRIDGE_PORT=8090 \ - AI_BACKEND_URL=http://hezarfen-backend:7656 \ + AI_BACKEND_URL=http://hezarfen_backend:7656 \ AI_SHARED_TOKEN=change-me \ AI_TLS_SERVER_NAME=localhost \ AI_SERVICE_NAME=celebi \ diff --git a/ReadMe.md b/ReadMe.md index ae6b0e3..856cb10 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -135,7 +135,7 @@ podman compose up -d --build # yalnız hezarfen-chatbot-bridge ``` Ürün compose'u demo HTTP sunucusunu çalıştırmaz ve hostta `8000/8001` portu -açmaz. Chatbot container'ı backend ağı içinde `hezarfen-backend:8090` hedefine +açmaz. Chatbot container'ı backend ağı içinde `hezarfen_backend:8090` hedefine **QUIC/UDP** ile bağlanır; `8090` için TCP bağlantısı veya host port yayını yoktur. `src.web` yalnız yerel geliştirici aracıdır ve ürün yığınının parçası değildir. diff --git a/compose.yaml b/compose.yaml index 2742d0c..286a125 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,11 +1,11 @@ # Çelebi QUIC köprüsü — bu compose yalnızca TEK chatbot container'ı oluşturur. # Backend compose ayakta olmalı; bu servis backend'in ağına katılır ve oradan -# QUIC/UDP ile `hezarfen-backend:8090` adresine dial-in eder. Host portu veya +# QUIC/UDP ile `hezarfen_backend:8090` adresine dial-in eder. Host portu veya # demo web arayüzü AÇMAZ (web.py yalnız geliştirici aracıdır). # # Varsayılanların TEK kaynağı Containerfile'ın ENV bloğudur; bu dosya hiçbir # `environment:` girdisi taşımaz, böylece hiçbir şey operatörün dosyasını -# gölgeleyemez. Sunucuda ~/hezarfen_chatbot/hezarfen_chatbot.env ile ezilir. +# gölgeleyemez. Sunucuda ~/hezarfen_rule_based_chatbot/hezarfen_rule_based_chatbot.env ile ezilir. # # podman compose up -d --build # @@ -19,12 +19,12 @@ services: context: . dockerfile: Containerfile # HEZARFEN_TAG deploy tarafından yazılan stack.env'den gelir (--env-file). - image: localhost/hezarfen_chatbot:${HEZARFEN_TAG:-latest} - container_name: hezarfen_chatbot + image: localhost/hezarfen_rule_based_chatbot:${HEZARFEN_TAG:-latest} + container_name: hezarfen_rule_based_chatbot init: true env_file: # Sunucuda elle yazılır (0600); laptopta yoktur. - - path: hezarfen_chatbot.env + - path: hezarfen_rule_based_chatbot.env required: false restart: unless-stopped networks: diff --git a/deploy/hezarfen_chatbot.env.example b/deploy/hezarfen_rule_based_chatbot.env.example similarity index 86% rename from deploy/hezarfen_chatbot.env.example rename to deploy/hezarfen_rule_based_chatbot.env.example index 905ff1c..40bf708 100644 --- a/deploy/hezarfen_chatbot.env.example +++ b/deploy/hezarfen_rule_based_chatbot.env.example @@ -1,10 +1,10 @@ -# hezarfen_chatbot.env — Çelebi köprüsünün sunucu ayarları. +# hezarfen_rule_based_chatbot.env — Çelebi köprüsünün sunucu ayarları. # # Sunucuda TEK SEFERLİK, elle: -# mkdir -p ~/hezarfen_chatbot -# cp hezarfen_chatbot.env.example ~/hezarfen_chatbot/hezarfen_chatbot.env +# mkdir -p ~/hezarfen_rule_based_chatbot +# cp hezarfen_rule_based_chatbot.env.example ~/hezarfen_rule_based_chatbot/hezarfen_rule_based_chatbot.env # -# chmod 0600 ~/hezarfen_chatbot/hezarfen_chatbot.env +# chmod 0600 ~/hezarfen_rule_based_chatbot/hezarfen_rule_based_chatbot.env # # Hiçbir otomasyon bu dosyayı oluşturmaz, ezmez, yüklemez — operatörün malıdır; # compose yalnız okur (`env_file`). Satırlar düz KEY=value: tırnak yok, `export` @@ -12,7 +12,7 @@ # # Buradaki her anahtar Containerfile ENV bloğundaki varsayılanı EZER. Değerler # konteyner BAŞLARKEN okunur: değişiklikten sonra yeniden oluştur -# (`podman compose up -d` ya da `systemctl --user restart hezarfen_chatbot_compose`). +# (`podman compose up -d` ya da `systemctl --user restart hezarfen_rule_based_chatbot_compose`). # ── Backend tarafı (ZORUNLU: ikisi backend ile aynı olmalı) ─────────────────── # Backend'in QUIC köprüsü dinleyicisi. hezarfen_backend.env içinde @@ -20,11 +20,11 @@ # konteyner loopback'ine bağlanır ve HİÇBİR servis dial-in edemez (Çelebi 503 # "no AI service is connected" verir). Değiştirdikten sonra: # systemctl --user restart hezarfen_backend_compose -AI_BRIDGE_HOST=hezarfen-backend +AI_BRIDGE_HOST=hezarfen_backend AI_BRIDGE_PORT=8090 # Sertifikanın çekildiği HTTP kökü — backend konteynerinin kendi portu. -AI_BACKEND_URL=http://hezarfen-backend:7656 +AI_BACKEND_URL=http://hezarfen_backend:7656 # Paylaşılan sır: backend'in AI_SHARED_TOKEN'ı ile BİREBİR aynı olmalı. # 'change-me' yalnız geliştirme değeridir; prod'da iki tarafı birlikte değiştir. diff --git a/deploy/hezarfen_chatbot_compose.service b/deploy/hezarfen_rule_based_chatbot_compose.service similarity index 72% rename from deploy/hezarfen_chatbot_compose.service rename to deploy/hezarfen_rule_based_chatbot_compose.service index 6427c61..4721ea4 100644 --- a/deploy/hezarfen_chatbot_compose.service +++ b/deploy/hezarfen_rule_based_chatbot_compose.service @@ -1,7 +1,7 @@ # systemd KULLANICI unit'i: Çelebi köprüsünü podman compose ile çalıştırır. -# %h/hezarfen_chatbot içinde beklenen dosyalar: +# %h/hezarfen_rule_based_chatbot içinde beklenen dosyalar: # compose.yaml bu repodan (ya da deploy artefaktından) -# hezarfen_chatbot.env 0600, deploy/hezarfen_chatbot.env.example'dan +# hezarfen_rule_based_chatbot.env 0600, deploy/hezarfen_rule_based_chatbot.env.example'dan # ELLE yazılır — otomasyon oluşturmaz/ezmez # stack.env deploy sahipli; HEZARFEN_TAG taşır # @@ -9,7 +9,7 @@ # podman compose build # burada derle # podman load -i image.tar # ya da hazır imajı yükle # -# hezarfen_chatbot.env içindeki anahtarlar (tam belge: deploy/hezarfen_chatbot.env.example). +# hezarfen_rule_based_chatbot.env içindeki anahtarlar (tam belge: deploy/hezarfen_rule_based_chatbot.env.example). # Hepsinin varsayılanı imajın ENV bloğundadır (Containerfile) — bu dosya ezer: # AI_BRIDGE_HOST / AI_BRIDGE_PORT backend'in QUIC dinleyicisi (ağ içi ad) # AI_BACKEND_URL sertifikanın çekildiği HTTP kökü @@ -18,7 +18,7 @@ # # Sadece ortam değişkeni değiştiğinde yeniden başlatma (ExecStart'ı yeniden # koşar, ortamı değişen konteynerı yeniden oluşturur): -# systemctl --user restart hezarfen_chatbot_compose +# systemctl --user restart hezarfen_rule_based_chatbot_compose [Unit] Description=Hezarfen Celebi QUIC bridge (rule-based chatbot) @@ -28,10 +28,10 @@ Wants=network-online.target [Service] Type=oneshot RemainAfterExit=yes -WorkingDirectory=%h/hezarfen_chatbot +WorkingDirectory=%h/hezarfen_rule_based_chatbot # Sonraki --env-file çakışan anahtarda kazanır: önce operatörün ayar dosyası, # sonra deploy sahipli stack.env (HEZARFEN_TAG). -ExecStart=/usr/bin/podman compose --env-file %h/hezarfen_chatbot/hezarfen_chatbot.env --env-file %h/hezarfen_chatbot/stack.env up -d --no-build +ExecStart=/usr/bin/podman compose --env-file %h/hezarfen_rule_based_chatbot/hezarfen_rule_based_chatbot.env --env-file %h/hezarfen_rule_based_chatbot/stack.env up -d --no-build # -v yok: isimli volume'lar stop'ta yaşamalı (köprü durumsuzdur ama şekil aynı). ExecStop=/usr/bin/podman compose down TimeoutStartSec=180