Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
yyq
7 years ago
Commit
e782783533b464d39ffb83c5c11cd24d7070e736
1 parent
28f10260
config
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
10 deletions
app.js
config/common.js
doraemon/middleware/yoho-session.js
utils/redis.js
app.js
View file @
e782783
...
...
@@ -40,12 +40,12 @@ const logger = global.yoho.logger;
// zookeeper
if
(
config
.
zookeeperServer
)
{
const
mointor
=
global
.
yoho
.
mointorSender
;
const
mointorType
=
_
.
get
(
mointor
,
'type.ZOOKEEPER'
);
const
monitor
=
global
.
yoho
.
monitorSender
;
const
monitorType
=
_
.
get
(
monitor
,
'type.ZOOKEEPER'
);
require
(
'yoho-zookeeper'
)(
config
.
zookeeperServer
,
'wap'
,
app
.
locals
.
wap
=
{},
false
,
{
onerror
:
(
err
)
=>
{
mo
intor
.
tallyFail
(
moin
torType
,
{
mo
nitor
.
tallyFail
(
moni
torType
,
{
code
:
err
.
code
,
message
:
err
.
name
});
...
...
config/common.js
View file @
e782783
...
...
@@ -240,6 +240,11 @@ if (isProduction) {
port
:
80
,
db
:
'web-apm'
},
monitorReport
:
{
host
:
'10.66.4.25'
,
port
:
8086
,
db
:
'web_monitor'
,
},
loggers
:
{
infoFile
:
{
name
:
'info'
,
...
...
@@ -308,6 +313,11 @@ if (isProduction) {
key
:
'7e6f3307b64cc87c79c472814b88f7fb'
,
appSecret
:
'ce21ae4a3f93852279175a167e54509b'
,
notifyUrl
:
(
process
.
env
.
TEST_SERVICE
||
'http://service-test1.yohops.com:9999/'
)
+
'payment/weixin_notify'
,
},
monitorReport
:
{
host
:
'192.168.102.22'
,
port
:
8086
,
db
:
'web_monitor'
,
}
});
}
...
...
doraemon/middleware/yoho-session.js
View file @
e782783
...
...
@@ -6,8 +6,8 @@ const uuid = require('uuid');
const
cookieSession
=
require
(
'client-sessions'
);
const
connectRedis
=
require
(
'connect-redis'
);
const
RedisStore
=
connectRedis
(
session
);
const
mointor
=
global
.
yoho
.
mointorSender
;
const
mointorType
=
_
.
get
(
mointor
,
'type.REDIS'
);
const
monitor
=
global
.
yoho
.
monitorSender
;
const
monitorType
=
_
.
get
(
monitor
,
'type.REDIS'
);
/**
* 该中间件主要把 express-session 和 client-session 集中起来处理,如果 redis 出错了,使用 cookie session
...
...
@@ -70,7 +70,7 @@ module.exports = (app) => {
store
:
new
RedisStore
(
Object
.
assign
(
config
.
redis
.
session
,
{
logErrors
:
(
e
)
=>
{
// 上报redis session错误
mo
intor
&&
mointor
.
tallyFail
(
moin
torType
,
e
);
mo
nitor
&&
monitor
.
tallyFail
(
moni
torType
,
e
);
}
}))
}));
...
...
utils/redis.js
View file @
e782783
...
...
@@ -3,7 +3,7 @@ const _ = require('lodash');
const
redis
=
require
(
'redis'
);
const
bluebird
=
require
(
'bluebird'
);
const
config
=
require
(
'../config/common'
);
const
mo
intor
=
global
.
yoho
.
moin
torSender
;
const
mo
nitor
=
global
.
yoho
.
moni
torSender
;
let
client
;
const
timeout
=
200
;
// redis 操作超时时间
...
...
@@ -13,7 +13,7 @@ try {
bluebird
.
promisifyAll
(
redis
.
RedisClient
.
prototype
);
bluebird
.
promisifyAll
(
redis
.
Multi
.
prototype
);
const
mo
intorType
=
_
.
get
(
moin
tor
,
'type.REDIS'
);
const
mo
nitorType
=
_
.
get
(
moni
tor
,
'type.REDIS'
);
client
.
all
=
args
=>
{
if
(
!
client
.
ready
)
{
...
...
@@ -25,10 +25,10 @@ try {
}
return
client
.
multi
.
call
(
client
,
args
).
execAsync
().
timeout
(
timeout
).
then
(
res
=>
{
mo
intor
&&
mointor
.
tallySuccess
(
moin
torType
);
mo
nitor
&&
monitor
.
tallySuccess
(
moni
torType
);
return
res
;
}).
catch
((
e
)
=>
{
mo
intor
&&
mointor
.
tallyFail
(
moin
torType
,
e
);
mo
nitor
&&
monitor
.
tallyFail
(
moni
torType
,
e
);
return
false
;
});
};
...
...
Please
register
or
login
to post a comment