Newer
Older
TelosDB / docs / config_deployment.md

Config.json 配置戦略

概要

config.json は環境に応じて異なる場所に配置されます。アプリケーションは以下の優先順位で設定ファイルを検索します。

検索優先順位

1. AppData/config.json (最優先)

  • 場所: %APPDATA%\sqlitevector\config.json (Windows)
  • 用途: ユーザーがカスタマイズした設定
  • 編集: ユーザーが自由に編集可能
  • シナリオ: 本番インストール後のカスタマイズ

2. プロジェクトルート/config.json

  • 場所: D:\develop\sqlitevector\config.json
  • 用途: 開発時・テスト時の設定
  • 編集: 開発者が編集
  • シナリオ:
    • 開発時: cargo run, bun run dev
    • テスト時: cargo build --release

3. resources/config.json

  • 場所: バンドル内 resources/config.json
  • 用途: 本番アプリのデフォルト設定
  • 編集: 読み取り専用(バンドルに埋め込まれる)
  • シナリオ: インストール直後のデフォルト

4. ハードコードデフォルト

  • 上記すべてが見つからない場合に使用
  • ソースコード内に定義

シナリオ別の動作

開発中 (bun run dev)

実行パス: D:\develop\sqlitevector\target\debug\app.exe
検索順:
  1. %APPDATA%\sqlitevector\config.json (存在しない)
  2. D:\develop\sqlitevector\target\debug\config.json (存在しない)
  3. D:\develop\sqlitevector\target\config.json (存在しない)
  4. D:\develop\sqlitevector\config.json ✓ 発見!

リリーステスト (cargo build --release)

実行パス: D:\develop\sqlitevector\target\release\app.exe
検索順:
  1. %APPDATA%\sqlitevector\config.json (存在しない)
  2. D:\develop\sqlitevector\target\release\config.json (存在しない)
  3. D:\develop\sqlitevector\target\config.json (存在しない)
  4. D:\develop\sqlitevector\config.json ✓ 発見!

本番インストール後(初回起動)

実行パス: C:\Program Files\sqlitevector\app.exe
検索順:
  1. %APPDATA%\sqlitevector\config.json (存在しない)
  2. C:\Program Files\sqlitevector\config.json (存在しない)
  3. C:\Program Files\sqlitevector\resources\config.json ✓ 発見!

本番インストール後(カスタマイズ後)

実行パス: C:\Program Files\sqlitevector\app.exe
検索順:
  1. %APPDATA%\sqlitevector\config.json ✓ 発見!(ユーザーがコピー・編集)

設定ファイルのカスタマイズ方法

開発時

プロジェクトルートの config.json を編集:

cd d:\develop\sqlitevector
notepad config.json

本番インストール後

  1. デフォルト設定をAppDataにコピー:

    # Windowsの場合
    $appData = "$env:APPDATA\sqlitevector"
    New-Item -ItemType Directory -Path $appData -Force
    Copy-Item "C:\Program Files\sqlitevector\resources\config.json" "$appData\config.json"
  2. コピーした設定を編集:

    notepad "$env:APPDATA\sqlitevector\config.json"
  3. アプリを再起動すると、カスタム設定が読み込まれる

config.json の構造

{
  "database": {
    "path": "data/vector.db"
  },
  "model": {
    "path": "models/embeddinggemma-300m-q4_0.gguf"
  },
  "llama_server": {
    "port": 8080
  }
}

パスの解釈

  • 相対パス: プロジェクトルートからの相対パス(開発時)または実行ファイルからの相対パス(本番時)
  • 絶対パス: そのまま使用

例:

{
  "database": {
    "path": "D:\\MyData\\vector.db"  // 絶対パス
  },
  "model": {
    "path": "models/mymodel.gguf"    // 相対パス
  }
}

トラブルシューティング

設定が読み込まれない

コンソール出力を確認:

✓ Loaded config from: "D:\\develop\\sqlitevector\\config.json"

または検索パスのリスト:

⚠ config.json not found. Searched in:
  - "C:\\Users\\username\\AppData\\Roaming\\sqlitevector\\config.json"
  - "D:\\develop\\sqlitevector\\config.json"
  - "C:\\Program Files\\sqlitevector\\resources\\config.json"
Using hardcoded defaults.

設定ファイルの場所を確認

アプリケーション起動時のログに Loaded config from: というメッセージが表示されます。

デフォルトに戻す

AppDataの設定ファイルを削除:

Remove-Item "$env:APPDATA\sqlitevector\config.json"

アプリを再起動すると、バンドルされたデフォルト設定が使用されます。