mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-22 09:09:08 +01:00
chore: add ROOT_DIR environment variable, refactor
This commit is contained in:
@@ -1,46 +1,10 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// file, folder structure
|
||||
|
||||
const (
|
||||
DotEnvPath = ".env"
|
||||
DotEnvExamplePath = ".env.example"
|
||||
|
||||
ConfigBasePath = "config"
|
||||
ConfigFileName = "config.yml"
|
||||
ConfigExampleFileName = "config.example.yml"
|
||||
ConfigPath = ConfigBasePath + "/" + ConfigFileName
|
||||
HomepageJSONConfigPath = ConfigBasePath + "/.homepage.json"
|
||||
IconListCachePath = ConfigBasePath + "/.icon_list_cache.json"
|
||||
IconCachePath = ConfigBasePath + "/.icon_cache.json"
|
||||
|
||||
MiddlewareComposeBasePath = ConfigBasePath + "/middlewares"
|
||||
|
||||
ComposeFileName = "compose.yml"
|
||||
ComposeExampleFileName = "compose.example.yml"
|
||||
|
||||
ErrorPagesBasePath = "error_pages"
|
||||
|
||||
AgentCertsBasePath = "certs"
|
||||
)
|
||||
|
||||
var RequiredDirectories = []string{
|
||||
ConfigBasePath,
|
||||
ErrorPagesBasePath,
|
||||
MiddlewareComposeBasePath,
|
||||
}
|
||||
import "time"
|
||||
|
||||
const DockerHostFromEnv = "$DOCKER_HOST"
|
||||
|
||||
const (
|
||||
HealthCheckIntervalDefault = 5 * time.Second
|
||||
HealthCheckTimeoutDefault = 5 * time.Second
|
||||
|
||||
WakeTimeoutDefault = "30s"
|
||||
StopTimeoutDefault = "30s"
|
||||
StopMethodDefault = "stop"
|
||||
)
|
||||
|
||||
@@ -19,6 +19,8 @@ var (
|
||||
IsDebug = GetEnvBool("DEBUG", IsTest)
|
||||
IsTrace = GetEnvBool("TRACE", false) && IsDebug
|
||||
|
||||
RootDir = GetEnvString("ROOT_DIR", "./")
|
||||
|
||||
HTTP3Enabled = GetEnvBool("HTTP3_ENABLED", true)
|
||||
|
||||
ProxyHTTPAddr,
|
||||
|
||||
31
internal/common/paths.go
Normal file
31
internal/common/paths.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// file, folder structure
|
||||
|
||||
var (
|
||||
ConfigDir = filepath.Join(RootDir, "config")
|
||||
ConfigFileName = "config.yml"
|
||||
ConfigExampleFileName = "config.example.yml"
|
||||
ConfigPath = filepath.Join(ConfigDir, ConfigFileName)
|
||||
|
||||
MiddlewareComposeDir = filepath.Join(ConfigDir, "middlewares")
|
||||
ErrorPagesDir = filepath.Join(RootDir, "error_pages")
|
||||
CertsDir = filepath.Join(RootDir, "certs")
|
||||
|
||||
DataDir = filepath.Join(RootDir, "data")
|
||||
MetricsDataDir = filepath.Join(DataDir, "metrics")
|
||||
|
||||
HomepageJSONConfigPath = filepath.Join(DataDir, "homepage.json")
|
||||
IconListCachePath = filepath.Join(DataDir, "icon_list_cache.json")
|
||||
IconCachePath = filepath.Join(DataDir, "icon_cache.json")
|
||||
)
|
||||
|
||||
var RequiredDirectories = []string{
|
||||
ConfigDir,
|
||||
ErrorPagesDir,
|
||||
MiddlewareComposeDir,
|
||||
}
|
||||
Reference in New Issue
Block a user