整合数据库配置,将所有配置合并到一个配置文件中 src的config.lua文件中
This commit is contained in:
parent
009e7dc201
commit
771c35d8ec
|
|
@ -11,6 +11,7 @@ return {
|
||||||
|
|
||||||
time_zone = "+8:00", -- UTC + 8
|
time_zone = "+8:00", -- UTC + 8
|
||||||
|
|
||||||
|
REDIS_PREFIX = 'Auth:',
|
||||||
-- 配置redis数据库连接
|
-- 配置redis数据库连接
|
||||||
REDIS = {
|
REDIS = {
|
||||||
HOST = "127.0.0.1", -- redis host
|
HOST = "127.0.0.1", -- redis host
|
||||||
|
|
@ -25,5 +26,10 @@ return {
|
||||||
USERNAME = "postgres",
|
USERNAME = "postgres",
|
||||||
PASSWORD = "1qaz2wsx", -- postgres password
|
PASSWORD = "1qaz2wsx", -- postgres password
|
||||||
DATABASE = "postgres",
|
DATABASE = "postgres",
|
||||||
|
|
||||||
|
CHARSET = 'utf8',
|
||||||
|
POOL_TIMEOUT = 1000, -- postgresql pool timeout
|
||||||
|
POOL_SIZE = 100, -- postgresql pool size
|
||||||
|
TIMEOUT = 1000, -- postgresql timeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
local env = require('config')
|
|
||||||
|
|
||||||
return {
|
|
||||||
redis_prefix = 'Auth:',
|
|
||||||
redis = {
|
|
||||||
host = env.REDIS.HOST,
|
|
||||||
port = env.REDIS.PORT,
|
|
||||||
password = env.REDIS.PASSWORD
|
|
||||||
},
|
|
||||||
|
|
||||||
postgres = {
|
|
||||||
host = env.POSTGRES.HOST,
|
|
||||||
port = env.POSTGRES.PORT,
|
|
||||||
user = env.POSTGRES.USERNAME,
|
|
||||||
password = env.POSTGRES.PASSWORD,
|
|
||||||
database = env.POSTGRES.DATABASE,
|
|
||||||
|
|
||||||
write = { -- postgresql write database
|
|
||||||
host = env.POSTGRES.HOST,
|
|
||||||
port = env.POSTGRES.PORT,
|
|
||||||
user = env.POSTGRES.USERNAME,
|
|
||||||
password = env.POSTGRES.PASSWORD,
|
|
||||||
database = env.POSTGRES.DATABASE
|
|
||||||
},
|
|
||||||
read = { -- postgresql read database
|
|
||||||
host = env.POSTGRES.HOST,
|
|
||||||
port = env.POSTGRES.PORT,
|
|
||||||
user = env.POSTGRES.USERNAME,
|
|
||||||
password = env.POSTGRES.PASSWORD,
|
|
||||||
database = env.POSTGRES.DATABASE
|
|
||||||
},
|
|
||||||
charset = 'utf8',
|
|
||||||
pool_timeout = 1000, -- postgresql pool timeout
|
|
||||||
pool_size = 100, -- postgresql pool size
|
|
||||||
timeout = 1000, -- postgresql timeout
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local Database = require('share.database')
|
local Database = require('share.database')
|
||||||
local dbconf = require("config.database")
|
local conf = require("config")
|
||||||
|
|
||||||
local helpers = require('share.helpers')
|
local helpers = require('share.helpers')
|
||||||
local implode = helpers.implode
|
local implode = helpers.implode
|
||||||
|
|
@ -12,28 +12,28 @@ local WRITE = 'WRITE'
|
||||||
local READ = 'READ'
|
local READ = 'READ'
|
||||||
|
|
||||||
local database_write = Database:new({
|
local database_write = Database:new({
|
||||||
host = dbconf.postgres.write.host,
|
host = conf.POSTGRES.host,
|
||||||
port = dbconf.postgres.write.port,
|
port = conf.POSTGRES.port,
|
||||||
user = dbconf.postgres.write.user,
|
user = conf.POSTGRES.user,
|
||||||
password = dbconf.postgres.write.password,
|
password = conf.POSTGRES.password,
|
||||||
database = dbconf.postgres.write.database,
|
database = conf.POSTGRES.database,
|
||||||
--charset = dbconf.postgres.charset,
|
--charset = conf.POSTGRES.charset,
|
||||||
--timeout = dbconf.postgres.timeout,
|
--timeout = conf.POSTGRES.timeout,
|
||||||
db_pool_timeout = dbconf.postgres.pool_timeout,
|
db_pool_timeout = conf.POSTGRES.pool_timeout,
|
||||||
db_pool_size = dbconf.postgres.pool_size,
|
db_pool_size = conf.POSTGRES.pool_size,
|
||||||
db_type = WRITE
|
db_type = WRITE
|
||||||
})
|
})
|
||||||
|
|
||||||
local database_read = Database:new({
|
local database_read = Database:new({
|
||||||
host = dbconf.postgres.read.host,
|
host = conf.POSTGRES.host,
|
||||||
port = dbconf.postgres.read.port,
|
port = conf.POSTGRES.port,
|
||||||
user = dbconf.postgres.read.user,
|
user = conf.POSTGRES.user,
|
||||||
password = dbconf.postgres.read.password,
|
password = conf.POSTGRES.password,
|
||||||
database = dbconf.postgres.read.database,
|
database = conf.POSTGRES.database,
|
||||||
--charset = dbconf.postgres.charset,
|
--charset = conf.POSTGRES.charset,
|
||||||
--timeout = dbconf.postgres.timeout,
|
--timeout = conf.POSTGRES.timeout,
|
||||||
db_pool_timeout = dbconf.postgres.pool_timeout,
|
db_pool_timeout = conf.POSTGRES.pool_timeout,
|
||||||
db_pool_size = dbconf.postgres.pool_size,
|
db_pool_size = conf.POSTGRES.pool_size,
|
||||||
db_type = READ
|
db_type = READ
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user