Merge pull request 'add prod mode' (#7) from develop into main
Reviewed-on: #7
This commit is contained in:
commit
7a44f2ede7
2 changed files with 13 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
.air.toml
|
||||
.env
|
||||
.env-dev
|
||||
tmp/*
|
||||
logs/*
|
||||
!logs/.gitkeep
|
||||
|
|
13
main.go
13
main.go
|
@ -26,14 +26,25 @@ var resources embed.FS
|
|||
func main() {
|
||||
app := core.New()
|
||||
basePath, err := os.Getwd()
|
||||
runMode := "dev"
|
||||
if len(os.Args) > 1 {
|
||||
if os.Args[1] == "prod" || os.Args[1] == "dev" {
|
||||
runMode = os.Args[1]
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatal("error getting current working dir")
|
||||
}
|
||||
app.SetBasePath(basePath)
|
||||
app.SetRunMode(runMode)
|
||||
app.MakeDirs("logs", "storage", "storage/sqlite", "tls")
|
||||
// Handle the reading of the .env file
|
||||
if config.GetEnvFileConfig().UseDotEnvFile {
|
||||
envVars, err := godotenv.Read(".env")
|
||||
envfile := ".env-dev"
|
||||
if runMode == "prod" {
|
||||
envfile = ".env"
|
||||
}
|
||||
envVars, err := godotenv.Read(envfile)
|
||||
if err != nil {
|
||||
log.Fatal("Error loading .env file")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue