mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-12 05:00:05 +00:00
refactor: prefix env variables of database with XUI_ to support direct environment usage without .env file
All database configuration environment variables now start with the XUI_ prefix to avoid conflicts and allow configuration via system-level environment variables, not just the .env file.
This commit is contained in:
parent
4d50320bc1
commit
e78f20a770
2 changed files with 12 additions and 12 deletions
12
.env.example
12
.env.example
|
@ -1,8 +1,8 @@
|
||||||
DB_CONNECTION=sqlite
|
XUI_DB_CONNECTION=sqlite
|
||||||
|
|
||||||
# If DB connection is "mysql"
|
# If DB connection is "mysql"
|
||||||
# DB_HOST=127.0.0.1
|
# XUI_DB_HOST=127.0.0.1
|
||||||
# DB_PORT=3306
|
# XUI_DB_PORT=3306
|
||||||
# DB_DATABASE=xui
|
# XUI_DB_DATABASE=xui
|
||||||
# DB_USERNAME=root
|
# XUI_DB_USERNAME=root
|
||||||
# DB_PASSWORD=
|
# XUI_DB_PASSWORD=
|
|
@ -76,12 +76,12 @@ type DatabaseConfig struct {
|
||||||
// GetDatabaseConfig returns the database configuration from environment variables
|
// GetDatabaseConfig returns the database configuration from environment variables
|
||||||
func GetDatabaseConfig() (*DatabaseConfig, error) {
|
func GetDatabaseConfig() (*DatabaseConfig, error) {
|
||||||
config := &DatabaseConfig{
|
config := &DatabaseConfig{
|
||||||
Connection: strings.ToLower(os.Getenv("DB_CONNECTION")),
|
Connection: strings.ToLower(os.Getenv("XUI_DB_CONNECTION")),
|
||||||
Host: os.Getenv("DB_HOST"),
|
Host: os.Getenv("XUI_DB_HOST"),
|
||||||
Port: os.Getenv("DB_PORT"),
|
Port: os.Getenv("XUI_DB_PORT"),
|
||||||
Database: os.Getenv("DB_DATABASE"),
|
Database: os.Getenv("XUI_DB_DATABASE"),
|
||||||
Username: os.Getenv("DB_USERNAME"),
|
Username: os.Getenv("XUI_DB_USERNAME"),
|
||||||
Password: os.Getenv("DB_PASSWORD"),
|
Password: os.Getenv("XUI_DB_PASSWORD"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Connection == "mysql" {
|
if config.Connection == "mysql" {
|
||||||
|
|
Loading…
Reference in a new issue