-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapted application for usage in docker with system parameters.
- Loading branch information
John Lennon
committed
Nov 17, 2020
1 parent
60afb53
commit f981e6f
Showing
8 changed files
with
88 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package cache | ||
|
||
import "os" | ||
|
||
var ( | ||
cacheHost = "localhost" | ||
cachePort = "6379" | ||
cachePassword = "" | ||
cacheHost = os.Getenv("CACHE_HOST") | ||
cachePort = os.Getenv("CACHE_PORT") | ||
cachePassword = os.Getenv("CACHE_PASSWORD") | ||
cacheDB = 0 | ||
CacheTTL = 0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
package database | ||
|
||
import "os" | ||
|
||
var ( | ||
dbHost = "localhost" // TODO: Change to environment variabe | ||
dbUser = "postgres" // TODO: Change to environment variabe | ||
dbPassword = "postgres" // TODO: Change to environment variabe | ||
dbDatabase = "collabyt" // TODO: Change to environment variabe | ||
dbPort = "5432" // TODO: Change to environment variabe | ||
dbHost = os.Getenv("DB_HOST") | ||
dbUser = os.Getenv("DB_USER") | ||
dbPassword = os.Getenv("DB_PASSWORD") | ||
dbDatabase = os.Getenv("DB_DATABASE") | ||
dbPort = os.Getenv("DB_PORT") | ||
|
||
dbSsl = "disable" // TODO: Change to environment variabe | ||
dbSource = "postgres" // TODO: Change to environment variabe | ||
dbSsl = os.Getenv("DB_SSL") | ||
dbSource = os.Getenv("DB_SOURCE") | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package startup | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"strconv" | ||
"time" | ||
|
||
"github.com/collabyt/Backend/cache" | ||
"github.com/collabyt/Backend/limiter" | ||
"github.com/gorilla/mux" | ||
) | ||
|
||
func SetupServer(r *mux.Router) (http.Server, error) { | ||
address := os.Getenv("APP_PORT") | ||
handler := limiter.Limit(cache.Cache, r) | ||
idleTimeout, err := strconv.Atoi(os.Getenv("APP_IDLE_TIMEOUT")) | ||
if err != nil { | ||
return http.Server{}, fmt.Errorf("server stup faile: impossible to get %s from system's parameters", "APP_IDLE_TIMEOUT") | ||
} | ||
readTimeout, err := strconv.Atoi(os.Getenv("APP_READ_TIMEOUT")) | ||
if err != nil { | ||
return http.Server{}, fmt.Errorf("server stup faile: impossible to get %s from system's parameters", "APP_READ_TIMEOUT") | ||
} | ||
writeTimeout, err := strconv.Atoi(os.Getenv("APP_WRITE_TIMEOUT")) | ||
if err != nil { | ||
return http.Server{}, fmt.Errorf("server stup faile: impossible to get %s from system's parameters", "APP_WRITE_TIMEOUT") | ||
} | ||
return http.Server{ | ||
Addr: address, | ||
Handler: handler, | ||
IdleTimeout: time.Duration(idleTimeout), | ||
ReadTimeout: time.Duration(readTimeout), | ||
WriteTimeout: time.Duration(writeTimeout), | ||
}, err | ||
} |