Merge pull request #64 from songquanpeng/main

Fork Sync: Update from parent repository
This commit is contained in:
quzard 2023-06-22 20:34:00 +08:00 committed by GitHub
commit 1427e66339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -154,7 +154,10 @@ sudo service nginx restart
2. 必须设置 `SQL_DSN`,使用 MySQL 数据库而非 SQLite所有服务器连接同一个数据库。
3. 所有从服务器必须设置 `SYNC_FREQUENCY`,以定期从数据库同步配置。
4. 从服务器可以选择设置 `FRONTEND_BASE_URL`,以重定向页面请求到主服务器。
5. 推荐每台服务器上都分别装好 Redis设置好 `REDIS_CONN_STRING`,这样可以做到在缓存未过期的情况下数据库零访问,可以减少延迟。
5. 从服务器上**分别**装好 Redis设置好 `REDIS_CONN_STRING`,这样可以做到在缓存未过期的情况下数据库零访问,可以减少延迟。
6. 如果主服务器访问数据库延迟也比较高,则也需要启用 Redis并设置 `SYNC_FREQUENCY`,以定期从数据库同步配置。
注意,设置 `SYNC_FREQUENCY` 后会导致从服务器的状态不会实时更新,而是定期同步。
环境变量的具体使用方法详见[此处](#环境变量)。

View File

@ -16,7 +16,7 @@ for ((i=1; i<=count; i++)); do
https://"$domain"/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $key" \
-d '{"prompt": "hi!", "max_tokens": 1, "model": "gpt-3.5-turbo"}')
-d '{"messages": [{"content": "echo hi", "role": "user"}], "model": "gpt-3.5-turbo", "stream": false, "max_tokens": 1}')
echo "$result"
total_time=$(bc <<< "$total_time + $result")
times+=("$result")

View File

@ -17,6 +17,11 @@ func InitRedisClient() (err error) {
SysLog("REDIS_CONN_STRING not set, Redis is not enabled")
return nil
}
if IsMasterNode {
SysLog("Redis is disabled on master node")
RedisEnabled = false
return nil
}
SysLog("Redis is enabled")
opt, err := redis.ParseURL(os.Getenv("REDIS_CONN_STRING"))
if err != nil {