This commit is contained in:
lightings 2023-05-19 11:38:32 +08:00
parent b3c5844124
commit 0b35eb3e7e
3 changed files with 10 additions and 7 deletions

View File

@ -18,7 +18,7 @@ const redisConfig = pomelo.app.get("redis");
app.use(globalChannel, { globalChannel: { app.use(globalChannel, { globalChannel: {
host: redisConfig.host, host: redisConfig.host,
port: redisConfig.port, port: redisConfig.port,
db: '0' db: redisConfig.db,
}}); }});
var chatRoute = function(session, msg, app, cb) { var chatRoute = function(session, msg, app, cb) {
@ -60,7 +60,7 @@ app.configure('production|development', 'master', function() {
const config = redisConfig; const config = redisConfig;
// cleanup redis // cleanup redis
const client = redis.createClient({ const client = redis.createClient({
url: `redis://${config.host}:${config.port}`, url: `redis://${config.host}:${config.port}/${config.db}`,
}); });
client.on("error", (err) => { client.on("error", (err) => {
@ -69,7 +69,7 @@ app.configure('production|development', 'master', function() {
async function init() { async function init() {
await client.connect(); await client.connect();
await client.flushAll(); await client.flushDb();
client.disconnect(); client.disconnect();
} }
init(); init();

View File

@ -6,7 +6,7 @@ const { query_game, query_guild } = require("../lib/db");
const config = pomelo.app.get("redis"); const config = pomelo.app.get("redis");
const client = redis.createClient({ const client = redis.createClient({
url: `redis://${config.host}:${config.port}`, url: `redis://${config.host}:${config.port}/${config.db}`,
}); });
client.on("error", (err) => { client.on("error", (err) => {

View File

@ -1,16 +1,19 @@
{ {
"development": { "development": {
"host" : "192.168.100.173", "host" : "192.168.100.173",
"port" : "6379" "port" : "6379",
"db" : 1
}, },
"production": { "production": {
"host" : "192.168.100.173", "host" : "192.168.100.173",
"port" : "6379" "port" : "6379",
"db" : 0
}, },
"dchat": { "dchat": {
"host" : "192.168.100.173", "host" : "192.168.100.173",
"port" : "6379" "port" : "6379",
"db" : 0
} }
} }