Commit 932b2396 authored by 郝聪敏's avatar 郝聪敏

添加redlock

parent 150ee165
This diff is collapsed.
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
module.exports = { module.exports = {
schedule: { schedule: {
cron: '*/1 * * * * *', cron: '*/10 * * * * *',
type: 'worker', type: 'worker',
immediate: true, immediate: true,
}, },
async task() { async task() {
// ctx.logger.info('定时任务开始'); // ctx.logger.info('定时任务开始');
// await ctx.service.home.sendMail(); // await ctx.service.home.schedule();
// ctx.logger.info('定时任务结束'); // ctx.logger.info('定时任务结束');
}, },
}; };
This diff is collapsed.
...@@ -82,10 +82,48 @@ module.exports = appInfo => { ...@@ -82,10 +82,48 @@ module.exports = appInfo => {
}, },
}; };
const redisConfig = {
redis: {
client: {
sentinels: [
{
host: 'opapi-redis1.quantgroups.com',
port: 26379,
},
{
host: 'opapi-redis2.quantgroups.com',
port: 26379,
},
{
host: 'opapi-redis3.quantgroups.com',
port: 26379,
},
],
name: 'mymaster',
password: '',
db: 0,
},
},
};
const redlock = {
redlock9: {
logger: app => e => app.info(e.message), // logger when lock failed, can be false
options: {
driftFactor: 0.01, // time in ms
retryCount: 0,
retryDelay: 200, // time in ms
retryJitter: 200, // time in ms
},
},
};
return { return {
...config, ...config,
...userConfig, ...userConfig,
...mailConfig, ...mailConfig,
...fdfsConfig, ...fdfsConfig,
...redisConfig,
...redlock,
}; };
}; };
...@@ -2,12 +2,16 @@ ...@@ -2,12 +2,16 @@
/** @type Egg.EggPlugin */ /** @type Egg.EggPlugin */
module.exports = { module.exports = {
// had enabled by egg
// static: {
// enable: true,
// }
amqplib: { amqplib: {
enable: true, enable: true,
package: 'egg-amqplib', package: 'egg-amqplib',
}, },
redis: {
enable: true,
package: 'egg-redis',
},
redlock9: {
enable: true,
package: 'egg-redlock-9',
},
}; };
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
"dependencies": { "dependencies": {
"egg": "^2.15.1", "egg": "^2.15.1",
"egg-amqplib": "^2.0.4", "egg-amqplib": "^2.0.4",
"egg-redis": "^2.4.0",
"egg-redlock-9": "^1.0.1",
"egg-scripts": "^2.11.0", "egg-scripts": "^2.11.0",
"fdfs": "^1.0.4", "fdfs": "^1.0.4",
"nodemailer-promise": "^2.0.0", "nodemailer-promise": "^2.0.0",
...@@ -27,7 +29,7 @@ ...@@ -27,7 +29,7 @@
"node": ">=10.0.0" "node": ">=10.0.0"
}, },
"scripts": { "scripts": {
"start": "egg-scripts start --title=egg-server-puppeteer", "start": "egg-scripts start --port=80 --title=egg-server-puppeteer",
"stop": "egg-scripts stop --title=egg-server-puppeteer", "stop": "egg-scripts stop --title=egg-server-puppeteer",
"dev": "egg-bin dev", "dev": "egg-bin dev",
"debug": "egg-bin debug", "debug": "egg-bin debug",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment