Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ type Config struct {
UniqueServiceName string `env:"STARHUB_SERVER_UNIQUE_SERVICE_NAME" default:""`
ServerFailureRedirectURL string `env:"STARHUB_SERVER_FAIL_REDIRECT_URL" default:"http://localhost:3000/errors/server-error"`
NeedPhoneVerify bool `env:"STARHUB_SERVER_NEED_PHONE_VERIFY" default:"false"`
// TimeZone is the application-wide timezone used for formatting
// timestamps (e.g. Loki log timestamps). It is not used by the
// database connection layer.
TimeZone string `env:"STARHUB_SERVER_TIMEZONE" default:"Asia/Shanghai"`

APIServer struct {
Port int `env:"STARHUB_SERVER_SERVER_PORT" default:"8080"`
Expand Down Expand Up @@ -76,7 +80,6 @@ type Config struct {
Database struct {
Driver string `env:"STARHUB_DATABASE_DRIVER" default:"pg"`
DSN string `env:"STARHUB_DATABASE_DSN" default:"postgresql://postgres:postgres@localhost:5432/starhub_server?sslmode=disable"`
TimeZone string `env:"STARHUB_DATABASE_TIMEZONE" default:"Asia/Shanghai"`
SearchConfiguration string `env:"STARHUB_DATABASE_SEARCH_CONFIGURATION" default:"opencsgchinese"`
}

Expand Down
2 changes: 1 addition & 1 deletion common/config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ api_token = "f3a7b9c1d6e5f8e2a1b5d4f9e6a2b8d7c3a4e2b1d9f6e7a8d2c5a7b4c1e3f5b8a1d
lbs_service_key = "123456"
city_to_cdn_domain = {}
docs_host = "http://localhost:6636"
timezone = "Asia/Shanghai"

[api_server]
port = 8080
Expand All @@ -31,7 +32,6 @@ lfs_concurrency = 5
[database]
driver = "pg"
dsn = "postgresql://postgres:postgres@localhost:5433/starhub_server?sslmode=disable"
timezone = "Asia/Shanghai"

[redis]
endpoint = "localhost:6379"
Expand Down
2 changes: 1 addition & 1 deletion component/reporter/sender/loki_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewLokiClient(url string, clientID types.ClientType, config *config.Config)
if err != nil {
slog.Error("failed to create loki client", slog.Any("error", err))
}
timeLoc, err := time.LoadLocation(config.Database.TimeZone)
timeLoc, err := time.LoadLocation(config.TimeZone)
if err != nil {
slog.Error("failed to create loki client by TimeZone error", slog.Any("error", err))
}
Expand Down
2 changes: 1 addition & 1 deletion component/reporter/sender/loki_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func TestNewLokiClient_ReturnsLogSender(t *testing.T) {
cfg.LogCollector.AcceptLabelPrefix = "csghub_"
cfg.LogCollector.LineSeparator = "\\n"
cfg.LogCollector.MaxStoreTimeDay = 7
cfg.Database.TimeZone = "UTC"
cfg.TimeZone = "UTC"

sender, err := NewLokiClient(server.URL, types.ClientType("test-client"), cfg)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-gitaly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ services:
memory: 2048M
environment:
STARHUB_DATABASE_DSN: postgresql://postgres:postgres@postgres:5432/starhub_server?sslmode=disable
STARHUB_DATABASE_TIMEZONE: Asia/Shanghai
STARHUB_SERVER_TIMEZONE: Asia/Shanghai
STARHUB_SERVER_REDIS_ENDPOINT: redis:6379
STARHUB_SERVER_GITSERVER_TYPE: gitaly
STARHUB_SERVER_GITALY_SERVER_SOCKET: tcp://gitaly:8075
Expand All @@ -336,7 +336,7 @@ services:
- postgres
environment:
STARHUB_DATABASE_DSN: postgresql://postgres:postgres@postgres:5432/starhub_server?sslmode=disable
STARHUB_DATABASE_TIMEZONE: Asia/Shanghai
STARHUB_SERVER_TIMEZONE: Asia/Shanghai
STARHUB_SERVER_REDIS_ENDPOINT: redis:6379
STARHUB_SERVER_MIRROR_REMOTE: false
STARHUB_SERVER_S3_ACCESS_KEY_ID: admin
Expand Down
270 changes: 30 additions & 240 deletions docs/en/config.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/en/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Before using Starhub Server locally, it is necessary to manually create the data
| --- | --- | --- |
| STARHUB_DATABASE_DRIVER | Database driver, e.g., pg | pg |
| STARHUB_DATABASE_DSN | Database connection DSN | postgresql://postgres:postgres@localhost:5432/starhub_server?sslmode=disable |
| STARHUB_DATABASE_TIMEZONE | Database timezone | Asia/Shanghai |
| STARHUB_SERVER_TIMEZONE | Application-wide timezone (used for formatting Loki log timestamps) | Asia/Shanghai |

## Initializing Database Migrations

Expand Down
251 changes: 30 additions & 221 deletions docs/zh-CN/config.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/zh-CN/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Migration 文件的名字有两个部分,时间戳和迁移名(也就是这
| --- | --- | --- |
| STARHUB_DATABASE_DRIVER | 数据库的 dirver,例如 pg | pg |
| STARHUB_DATABASE_DSN | 数据库的连接 DSN | postgresql://postgres:postgres@localhost:5432/starhub_server?sslmode=disable |
| STARHUB_DATABASE_TIMEZONE | 数据库的时区 | Asia/Shanghai |
| STARHUB_SERVER_TIMEZONE | 应用全局时区(用于格式化 Loki 日志时间戳) | Asia/Shanghai |

## 初始化数据库迁移

Expand Down
Loading