From 6e1a0a914253f41ce914385809e1374b43243e74 Mon Sep 17 00:00:00 2001 From: Do Minh Khai Date: Mon, 18 Mar 2019 10:03:12 +0700 Subject: [PATCH] remove slack-notify --- server/config/default.json | 1 - server/config/devnet.json | 9 ++++----- server/config/mainnet.json | 1 - server/config/testnet.json | 5 ++--- server/package-lock.json | 9 --------- server/package.json | 1 - server/src/index.js | 13 ------------- server/src/producer.js | 28 ---------------------------- 8 files changed, 6 insertions(+), 61 deletions(-) diff --git a/server/config/default.json b/server/config/default.json index ec8593ad..ce65d693 100644 --- a/server/config/default.json +++ b/server/config/default.json @@ -48,7 +48,6 @@ "BASE_URL": "https://scan.testnet.tomochain.com/", "CLIENT_URL": "http://localhost:3000/", "TOMOMASTER_API_URL": "https://master.testnet.tomochain.com", - "SLACK_WEBHOOK_URL": "", "BLOCK_PER_EPOCH": 900, "REWARD": 250, diff --git a/server/config/devnet.json b/server/config/devnet.json index f6d4ff43..ea11df75 100644 --- a/server/config/devnet.json +++ b/server/config/devnet.json @@ -32,8 +32,8 @@ } ], - "WEB3_URI": "https://testnet.tomochain.com/", - "WEB3_WS_URI": "wss://testnet.tomochain.com/ws", + "WEB3_URI": "https://devnet.tomochain.com/", + "WEB3_WS_URI": "wss://devnet.tomochain.com/ws", "DEBUG_QUERY": false, "BASE_UNIT": "TOMO", @@ -46,10 +46,9 @@ "SENDGRID_API_KEY": "", "SENDER_EMAIL": "contact@tomochain.com", - "BASE_URL": "https://scan.testnet.tomochain.com/", + "BASE_URL": "https://scan.devnet.tomochain.com/", "CLIENT_URL": "http://localhost:3000/", - "TOMOMASTER_API_URL": "https://master.testnet.tomochain.com", - "SLACK_WEBHOOK_URL": "", + "TOMOMASTER_API_URL": "https://master.devnet.tomochain.com", "BLOCK_PER_EPOCH": 900, "REWARD": 250, diff --git a/server/config/mainnet.json b/server/config/mainnet.json index 52ad884b..ab24a2f9 100644 --- a/server/config/mainnet.json +++ b/server/config/mainnet.json @@ -57,7 +57,6 @@ "BASE_URL": "https://scan.tomochain.com/", "CLIENT_URL": "http://localhost:3000/", "TOMOMASTER_API_URL": "https://master.tomochain.com", - "SLACK_WEBHOOK_URL": "", "BLOCK_PER_EPOCH": 900, "REWARD": 250, diff --git a/server/config/testnet.json b/server/config/testnet.json index 1bb6f080..cc778b53 100644 --- a/server/config/testnet.json +++ b/server/config/testnet.json @@ -46,10 +46,9 @@ "SENDGRID_API_KEY": "", "SENDER_EMAIL": "contact@tomochain.com", - "BASE_URL": "https://scan.devnet.tomochain.com/", + "BASE_URL": "https://scan.testnet.tomochain.com/", "CLIENT_URL": "http://localhost:3000/", - "TOMOMASTER_API_URL": "https://master.devnet.tomochain.com", - "SLACK_WEBHOOK_URL": "", + "TOMOMASTER_API_URL": "https://master.testnet.tomochain.com", "BLOCK_PER_EPOCH": 900, "REWARD": 250, diff --git a/server/package-lock.json b/server/package-lock.json index 2ba0c2b7..49df6fe3 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -7026,15 +7026,6 @@ } } }, - "slack-notify": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/slack-notify/-/slack-notify-0.1.7.tgz", - "integrity": "sha512-eDWa4JTy77xbuOM8fZHqBFcEh+xDlol6gttnFxKFwNS0iNayzQ2G1cgbyHXSmBhk/55vooX15ar6W9DnEhw6yQ==", - "requires": { - "lodash": "^4.17.10", - "request": "^2.51.0" - } - }, "slice-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", diff --git a/server/package.json b/server/package.json index 9efb5415..f19e65dd 100644 --- a/server/package.json +++ b/server/package.json @@ -55,7 +55,6 @@ "passport": "^0.4.0", "passport-jwt": "^4.0.0", "pug": "^2.0.3", - "slack-notify": "^0.1.7", "socket.io": "^2.1.0", "solc": "^0.4.25", "string-template": "^1.0.0", diff --git a/server/src/index.js b/server/src/index.js index 2762478e..ab91dc7e 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -48,19 +48,6 @@ mongoose.connect(config.get('MONGODB_URI'), { useCreateIndex: true, useNewUrlPar } else { // Initialize public api app.use('/api', api) - - // Production error handler - if (config.get('APP_ENV') === 'prod') { - app.use(function (err, req, res, next) { - var slack = require('slack-notify')(config.get('SLACK_WEBHOOK_URL')) - slack.send({ - channel: '#tm_explorer', - text: err.stack - }) - - res.sendStatus(err.status || 500) - }) - } } }) diff --git a/server/src/producer.js b/server/src/producer.js index 3c000ecb..330ccc17 100644 --- a/server/src/producer.js +++ b/server/src/producer.js @@ -4,7 +4,6 @@ const Web3Util = require('./helpers/web3') const q = require('./queues') const db = require('./models') const events = require('events') -// const config = require('config') const logger = require('./helpers/logger') // fix warning max listener @@ -26,8 +25,6 @@ let countJobs = () => { const watch = async () => { try { - // let isSend = false - // let isOver2Minutes = 0 let step = 100 let setting = await db.Setting.findOne({ meta_key: 'min_block_crawl' }) let newJobSetting = await db.Setting.findOne({ meta_key: 'push_new_job' }) @@ -79,34 +76,9 @@ const watch = async () => { if (minBlockCrawl > parseInt(setting.meta_value)) { setting.meta_value = minBlockCrawl - // isOver2Minutes = 0 - // isSend = true await setting.save() newJobSetting = await db.Setting.findOne({ meta_key: 'push_new_job' }) } - - // if (String(maxBlockNum) === String(minBlockCrawl)) { - // isOver2Minutes += 0.5 // Similar to 0.5 second - // - // // send notification after 2 minutes - // if (isOver2Minutes >= 240 && isSend) { - // let slack = require('slack-notify')(config.get('SLACK_WEBHOOK_URL')) - // logger.info('Slack Notification - There is no new block in last 2 minutes') - // await slack.send({ - // attachments: [ - // { - // author_name: 'Slack Bot', - // title: ':warning: WARNING', - // color: 'danger', - // text: ' There is no new block in last 2 minutes' - // } - // ] - // }) - // isSend = false - // } - // logger.debug('Sleep 0.5 seconds') - // await sleep(500) - // } } } } catch (e) {