Compare View
Commits (6)
Changes
Showing 5 changed files Side-by-side Diff
index.js
1 | 1 | "use strict"; |
2 | 2 | |
3 | -global.KOMODO_LOG_LABEL = 'MESSAGING'; | |
4 | - | |
5 | 3 | process.chdir(__dirname); |
6 | 4 | const fs = require('fs'); |
7 | 5 | fs.writeFileSync('pid.txt', process.pid); |
8 | 6 | |
7 | +global.KOMODO_LOG_LABEL = 'KOMODO-MESSAGING'; | |
8 | +process.title = global.KOMODO_LOG_LABEL; | |
9 | + | |
9 | 10 | const matrix = require('komodo-sdk/matrix'); |
10 | 11 | matrix.NODE_ENV = process.env.NODE_ENV; |
11 | 12 |
lib/command-handler/index.js
... | ... | @@ -33,7 +33,7 @@ function execute(msg, params, cb) { |
33 | 33 | |
34 | 34 | const tokens = commandParser.splitToken(msg); |
35 | 35 | const commandGroup = commandParser.extractCommandGroup(tokens); |
36 | - logger.verbose('Got new message from partner', {msg: msg, params: params, tokens: tokens, commandGroup: commandGroup}); | |
36 | + logger.info('Processing message from partner', {msg: msg, params: params, tokens: tokens, commandGroup: commandGroup}); | |
37 | 37 | |
38 | 38 | if (!commandGroup || commandGroup === 'buy') { |
39 | 39 | handlerBuy(tokens, params, cb); |
lib/messages-archive.js
... | ... | @@ -9,10 +9,12 @@ const db = require('./db-mysql'); |
9 | 9 | const DIRECTION_INCOMING = 0; |
10 | 10 | const DIRECTION_OUTGOING = 1; |
11 | 11 | |
12 | -const redisClient = config.redis && redis.createClient(config.redis); | |
12 | +let redisClient; | |
13 | 13 | |
14 | 14 | if (!config.redis) { |
15 | 15 | logger.warn('Undefined config.redis, messages counter will not work! #05A778E21D7E'); |
16 | +} else { | |
17 | + redisClient = redis.createClient(config.redis); | |
16 | 18 | } |
17 | 19 | |
18 | 20 | if (!redisClient) { |
... | ... | @@ -25,8 +27,11 @@ function composeRedisCounterKeyword(origin, direction) { |
25 | 27 | } |
26 | 28 | |
27 | 29 | function incrementCounter(origin, direction) { |
28 | - logger.warn('Undefined redisClient, not incrementing messages counter! #FF8E765E12E2'); | |
29 | - redisClient && redisClient.INCR(composeRedisCounterKeyword(origin, direction), () => {}); | |
30 | + if (!redisClient) { | |
31 | + logger.warn('Undefined redisClient, not incrementing messages counter! #FF8E765E12E2'); | |
32 | + } else { | |
33 | + redisClient.INCR(composeRedisCounterKeyword(origin, direction), () => {}); | |
34 | + } | |
30 | 35 | } |
31 | 36 | |
32 | 37 | /** |
... | ... | @@ -44,7 +49,7 @@ function incrementCounter(origin, direction) { |
44 | 49 | function insert(params, direction) { |
45 | 50 | incrementCounter( |
46 | 51 | params.origin_label || params.origin, |
47 | - params.direction | |
52 | + direction | |
48 | 53 | ); |
49 | 54 | |
50 | 55 | if (!db.pool) return; |
package-lock.json