Restructure app
This commit is contained in:
19
app/main.go
19
app/main.go
@ -2,9 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"iris-test/app/cfg"
|
||||
"iris-test/app/db"
|
||||
"iris-test/app/logging"
|
||||
"iris-test/app/views"
|
||||
"time"
|
||||
|
||||
@ -16,17 +13,17 @@ import (
|
||||
var redisDB *redis.Database
|
||||
|
||||
func createSessionEngine() *sessions.Sessions {
|
||||
redisAddr := fmt.Sprintf("%s:%d", cfg.Config.Redis.Host, cfg.Config.Redis.Port)
|
||||
redisAddr := fmt.Sprintf("%s:%d", Config.Redis.Host, Config.Redis.Port)
|
||||
|
||||
redisDB = redis.New(redis.Config{
|
||||
Network: "tcp",
|
||||
Addr: redisAddr,
|
||||
Timeout: time.Duration(30) * time.Second,
|
||||
MaxActive: 10,
|
||||
Username: cfg.Config.Redis.Username,
|
||||
Password: cfg.Config.Redis.Password,
|
||||
Database: cfg.Config.Redis.Database,
|
||||
Prefix: cfg.Config.Redis.Prefix,
|
||||
Username: Config.Redis.Username,
|
||||
Password: Config.Redis.Password,
|
||||
Database: Config.Redis.Database,
|
||||
Prefix: Config.Redis.Prefix,
|
||||
Driver: redis.GoRedis(), // defaults to this driver.
|
||||
// To set a custom, existing go-redis client, use the "SetClient" method:
|
||||
// Driver: redis.GoRedis().SetClient(customGoRedisClient)
|
||||
@ -54,9 +51,9 @@ func createApp() *iris.Application {
|
||||
}
|
||||
|
||||
func main() {
|
||||
cfg.Init()
|
||||
logging.Init()
|
||||
db.InitDB()
|
||||
InitCfg()
|
||||
InitLogging()
|
||||
InitDB()
|
||||
|
||||
app := createApp()
|
||||
defer redisDB.Close()
|
||||
|
||||
Reference in New Issue
Block a user