Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
李奇
7 years ago
Commit
33f899a94416736a14977ebe055dc851105753b4
1 parent
da0ce8bb
redis transition
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
141 additions
and
95 deletions
app.js
config/common.js
package.json
yarn.lock
app.js
View file @
33f899a
...
...
@@ -19,9 +19,9 @@ const bodyParser = require('body-parser');
const
cookieParser
=
require
(
'cookie-parser'
);
const
favicon
=
require
(
'serve-favicon'
);
const
CookieSession
=
require
(
'client-sessions'
);
const
MemcachedSession
=
require
(
'yoho-express-session'
);
const
memcached
=
require
(
'connect-memcached'
);
const
MemcachedStore
=
memcached
(
MemcachedSession
);
const
session
=
require
(
'yoho-express-session'
);
const
redis
=
require
(
'connect-redis'
);
const
RedisStore
=
redis
(
session
);
const
hbs
=
require
(
'express-handlebars'
);
const
multer
=
require
(
'connect-multiparty'
);
const
pkg
=
require
(
'./package.json'
);
...
...
@@ -57,7 +57,7 @@ app.use(bodyParser.urlencoded({extended: true}));
app
.
use
(
cookieParser
());
app
.
use
(
multer
());
app
.
use
(
MemcachedS
ession
({
// eslint-disable-line
app
.
use
(
s
ession
({
// eslint-disable-line
proxy
:
true
,
resave
:
false
,
saveUninitialized
:
true
,
...
...
@@ -68,13 +68,7 @@ app.use(MemcachedSession({ // eslint-disable-line
domain
:
config
.
cookieDomain
,
httpOnly
:
false
},
store
:
new
MemcachedStore
({
hosts
:
config
.
memcache
.
session
,
prefix
:
'yohoblk-session:'
,
reconnect
:
5000
,
timeout
:
1000
,
retries
:
0
})
store
:
new
RedisStore
(
config
.
redis
.
session
)
}));
app
.
use
(
CookieSession
({
// eslint-disable-line
...
...
@@ -100,8 +94,8 @@ app.use((req, res, next) => {
}
req
.
session2
.
sessionBack
=
req
.
session
;
}
else
{
req
.
session
=
new
MemcachedSession
.
Session
(
req
);
req
.
session
.
cookie
=
new
MemcachedSession
.
Cookie
({
req
.
session
=
new
session
.
Session
(
req
);
req
.
session
.
cookie
=
new
session
.
Cookie
({
domain
:
'yohoblk.com'
,
httpOnly
:
false
});
...
...
config/common.js
View file @
33f899a
...
...
@@ -44,12 +44,31 @@ module.exports = {
},
useOneapm
:
false
,
useCache
:
false
,
memcache
:
{
master
:
[
'127.0.0.1:11211'
],
slave
:
[
'127.0.0.1:11211'
],
session
:
[
'127.0.0.1:11211'
],
timeout
:
1000
,
retries
:
0
redis
:
{
connect
:
{
host
:
'127.0.0.1'
,
// host: '192.168.102.49',
port
:
'6379'
,
retry_strategy
(
options
)
{
if
(
options
.
error
&&
options
.
error
.
code
===
'ECONNREFUSED'
)
{
console
.
log
(
'redis连接不成功'
);
}
if
(
options
.
total_retry_time
>
1000
*
60
*
60
*
6
)
{
console
.
log
(
'redis连接超时'
);
return
;
}
if
(
options
.
attempt
>
10
)
{
return
1000
*
60
*
60
*
0.5
;
}
return
Math
.
min
(
options
.
attempt
*
100
,
1000
);
}
},
session
:
{
host
:
'127.0.01'
,
port
:
'6379'
,
prefix
:
'yohoblk-session:'
}
},
interfaceShunt
:
{
useInterfaceShunt
:
false
,
...
...
@@ -76,12 +95,6 @@ module.exports = {
handleExceptions
:
true
,
maxFiles
:
7
},
udp
:
{
// send by udp
measurement
:
'yohoblk_pc_log'
,
level
:
'debug'
,
// logger level
host
:
'influxdblog.yohoops.org'
,
// influxdb host
port
:
'4444'
// influxdb port
},
console
:
{
close
:
true
,
level
:
'debug'
,
...
...
@@ -112,6 +125,11 @@ module.exports = {
},
crypto
:
{
common
:
'yohoblk9646abcde'
},
report
:
{
host
:
'localhost'
,
port
:
6009
,
db
:
'web-apm'
}
};
...
...
@@ -124,14 +142,33 @@ if (isProduction) {
service
:
'http://service.yoho.yohoops.org/'
,
search
:
'http://search.yohoops.org/yohosearch/'
},
memcache
:
{
master
:
[
'memcache1.yohoops.org:12111'
,
'memcache2.yohoops.org:12111'
,
'memcache3.yohoops.org:12111'
],
slave
:
[
'memcache1.yohoops.org:12112'
,
'memcache2.yohoops.org:12112'
,
'memcache3.yohoops.org:12112'
],
session
:
[
'memcache1.yohoops.org:12111'
,
'memcache2.yohoops.org:12111'
,
'memcache3.yohoops.org:12111'
],
timeout
:
3000
},
useOneapm
:
true
,
useCache
:
true
,
redis
:
{
connect
:
{
host
:
'web.redis.yohoops.org'
,
port
:
'6379'
,
retry_strategy
(
options
)
{
if
(
options
.
error
&&
options
.
error
.
code
===
'ECONNREFUSED'
)
{
console
.
log
(
'redis连接不成功'
);
}
if
(
options
.
total_retry_time
>
1000
*
60
*
60
*
6
)
{
console
.
log
(
'redis连接超时'
);
return
;
}
if
(
options
.
attempt
>
10
)
{
return
1000
*
60
*
60
*
0.5
;
}
return
Math
.
min
(
options
.
attempt
*
100
,
1000
);
}
},
session
:
{
host
:
'redis.web.yohoops.org'
,
port
:
'6379'
,
pass
:
'redis9646'
,
prefix
:
'yohoblk_session:'
}
},
pay
:
{
serviceNotify
:
'http://service.yoho.cn/'
},
...
...
@@ -145,6 +182,11 @@ if (isProduction) {
api
:
'app-java-168863769.cn-north-1.elb.amazonaws.com.cn'
,
service
:
'service-yoho-579825100.cn-north-1.elb.amazonaws.com.cn'
}
},
report
:
{
host
:
'badjs.yoho.cn'
,
port
:
80
,
db
:
'web-apm'
}
});
}
else
if
(
isTest
)
{
...
...
@@ -158,13 +200,6 @@ if (isProduction) {
},
useOneapm
:
true
,
useCache
:
true
,
memcache
:
{
master
:
[
'127.0.0.1:12111'
],
slave
:
[
'127.0.0.1:12112'
],
session
:
[
'127.0.0.1:12111'
],
timeout
:
1000
,
retries
:
0
},
pay
:
{
serviceNotify
:
'http://service-test3.yohops.com:9999/'
}
...
...
package.json
View file @
33f899a
...
...
@@ -37,6 +37,7 @@
"captchapng"
:
"0.0.1"
,
"client-sessions"
:
"^0.7.0"
,
"connect-multiparty"
:
"^2.0.0"
,
"connect-redis"
:
"^3.3.3"
,
"cookie-parser"
:
"^1.4.3"
,
"csurf"
:
"^1.9.0"
,
"express"
:
"^4.13.1"
,
...
...
@@ -65,9 +66,8 @@
"winston-daily-rotate-file"
:
"^1.1.4"
,
"xml2js"
:
"^0.4.17"
,
"xss"
:
"^0.2.13"
,
"connect-memcached"
:
"^0.2.0"
,
"yoho-express-session"
:
"^2.0.0"
,
"yoho-node-lib"
:
"
0.2.22
"
"yoho-node-lib"
:
"
=0.6.6
"
},
"devDependencies"
:
{
"autoprefixer"
:
"^6.3.6"
,
...
...
@@ -107,6 +107,7 @@
"webpack"
:
"^1.13.1"
,
"webpack-dev-server"
:
"^1.14.1"
,
"webpack-stream"
:
"^3.1.0"
,
"yoho-cookie"
:
"^1.2.0"
,
"yoho-eventproxy"
:
"^0.3.6"
,
"yoho-handlebars"
:
"^4.0.5"
,
"yoho-jquery"
:
"^1.12.4"
,
...
...
@@ -117,7 +118,6 @@
"yoho-jquery-placeholder"
:
"^2.3.1"
,
"yoho-jquery-qrcode"
:
"0.0.3"
,
"yoho-json2"
:
"^1.0.0"
,
"yoho-cookie"
:
"^1.2.0"
,
"yoho-slider"
:
"0.0.2"
}
}
\ No newline at end of file
}
...
...
yarn.lock
View file @
33f899a
...
...
@@ -1759,12 +1759,6 @@ connect-history-api-fallback@^1.3.0:
version "1.5.0"
resolved "http://npm.yohops.com/connect-history-api-fallback/-/connect-history-api-fallback-1.5.0.tgz#b06873934bc5e344fef611a196a6faae0aee015a"
connect-memcached@^0.2.0:
version "0.2.0"
resolved "http://npm.yohops.com/connect-memcached/-/connect-memcached-0.2.0.tgz#64907180324e117d9e8f299c994c0cb03d5020cf"
dependencies:
memcached "2.2.x"
connect-multiparty@^2.0.0:
version "2.1.0"
resolved "http://npm.yohops.com/connect-multiparty/-/connect-multiparty-2.1.0.tgz#b562232ea638e13222d87e7b67be437f7ad89814"
...
...
@@ -1774,9 +1768,12 @@ connect-multiparty@^2.0.0:
qs "~6.5.1"
type-is "~1.6.15"
connection-parse@0.0.x:
version "0.0.7"
resolved "http://npm.yohops.com/connection-parse/-/connection-parse-0.0.7.tgz#18e7318aab06a699267372b10c5226d25a1c9a69"
connect-redis@^3.3.3:
version "3.3.3"
resolved "http://npm.yohops.com/connect-redis/-/connect-redis-3.3.3.tgz#0fb8f370192f62da75ec7a9507807599fbe15b37"
dependencies:
debug "^3.1.0"
redis "^2.1.0"
console-browserify@^1.1.0:
version "1.1.0"
...
...
@@ -2123,7 +2120,7 @@ debug@2.6.9, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.6.
dependencies:
ms "2.0.0"
debug@3.X, debug@^3.0.0, debug@^3.1.0:
debug@3.X, debug@^3.0.0, debug@^3.
0.1, debug@^3.
1.0:
version "3.1.0"
resolved "http://npm.yohops.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies:
...
...
@@ -2263,6 +2260,13 @@ dir-glob@^2.0.0:
arrify "^1.0.1"
path-type "^3.0.0"
dnscache@^1.0.1:
version "1.0.1"
resolved "http://npm.yohops.com/dnscache/-/dnscache-1.0.1.tgz#42cb2b9bfb5e8fbdfa395aac74e127fc05074d31"
dependencies:
asap "~2.0.3"
lodash.clone "~4.3.2"
doctrine@^1.2.2:
version "1.5.0"
resolved "http://npm.yohops.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa"
...
...
@@ -2331,6 +2335,10 @@ dot-prop@^4.1.1:
dependencies:
is-obj "^1.0.0"
double-ended-queue@^2.1.0-0:
version "2.1.0-0"
resolved "http://npm.yohops.com/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz#103d3527fd31528f40188130c841efdd78264e5c"
duplexer2@0.0.2, duplexer2@~0.0.2:
version "0.0.2"
resolved "http://npm.yohops.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db"
...
...
@@ -3661,13 +3669,6 @@ has@^1.0.0, has@^1.0.1:
dependencies:
function-bind "^1.0.2"
hashring@3.2.x:
version "3.2.0"
resolved "http://npm.yohops.com/hashring/-/hashring-3.2.0.tgz#fda4efde8aa22cdb97fb1d2a65e88401e1c144ce"
dependencies:
connection-parse "0.0.x"
simple-lru-cache "0.0.x"
hawk@3.1.3, hawk@~3.1.3:
version "3.1.3"
resolved "http://npm.yohops.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4"
...
...
@@ -3852,6 +3853,14 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"
influx-batch-sender@^0.1.5:
version "0.1.5"
resolved "http://npm.yohops.com/influx-batch-sender/-/influx-batch-sender-0.1.5.tgz#865a5eb9a446f4e8ed442ab44e67c3532c27a5d7"
dependencies:
debug "^3.0.1"
lodash "^4.17.4"
request "^2.83.0"
influxdb-winston@^1.0.1:
version "1.0.1"
resolved "http://npm.yohops.com/influxdb-winston/-/influxdb-winston-1.0.1.tgz#e01af018a557caf11a292bf20f9fa04a8672a9de"
...
...
@@ -4297,12 +4306,6 @@ istanbul@^0.4.3:
which "^1.1.1"
wordwrap "^1.0.0"
jackpot@>=0.0.6:
version "0.0.6"
resolved "http://npm.yohops.com/jackpot/-/jackpot-0.0.6.tgz#3cff064285cbf66f4eab2593c90bce816a821849"
dependencies:
retry "0.6.0"
jpeg-js@0.0.4:
version "0.0.4"
resolved "http://npm.yohops.com/jpeg-js/-/jpeg-js-0.0.4.tgz#06aaf47efec7af0b1924a59cd695a6d2b5ed870e"
...
...
@@ -4577,6 +4580,10 @@ lodash._baseassign@^3.0.0:
lodash._basecopy "^3.0.0"
lodash.keys "^3.0.0"
lodash._baseclone@~4.5.0:
version "4.5.7"
resolved "http://npm.yohops.com/lodash._baseclone/-/lodash._baseclone-4.5.7.tgz#ce42ade08384ef5d62fa77c30f61a46e686f8434"
lodash._basecopy@^3.0.0:
version "3.0.1"
resolved "http://npm.yohops.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
...
...
@@ -4641,6 +4648,12 @@ lodash.clone@^4.3.2:
version "4.5.0"
resolved "http://npm.yohops.com/lodash.clone/-/lodash.clone-4.5.0.tgz#195870450f5a13192478df4bc3d23d2dea1907b6"
lodash.clone@~4.3.2:
version "4.3.2"
resolved "http://npm.yohops.com/lodash.clone/-/lodash.clone-4.3.2.tgz#e56b176b6823a7dde38f7f2bf58de7d5971200e9"
dependencies:
lodash._baseclone "~4.5.0"
lodash.debounce@^4.0.3:
version "4.0.8"
resolved "http://npm.yohops.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
...
...
@@ -4768,7 +4781,7 @@ lru-cache@2:
version "2.7.3"
resolved "http://npm.yohops.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952"
lru-cache@^4.0.1:
lru-cache@^4.0.1
, lru-cache@^4.1.1
:
version "4.1.2"
resolved "http://npm.yohops.com/lru-cache/-/lru-cache-4.1.2.tgz#45234b2e6e2f2b33da125624c4664929a0224c3f"
dependencies:
...
...
@@ -4868,13 +4881,6 @@ media-typer@0.3.0:
version "0.3.0"
resolved "http://npm.yohops.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
memcached@2.2.x, memcached@^2.2.2:
version "2.2.2"
resolved "http://npm.yohops.com/memcached/-/memcached-2.2.2.tgz#68f86ccfd84bcf93cc25ed46d6d7fc0c7521c9d5"
dependencies:
hashring "3.2.x"
jackpot ">=0.0.6"
memoizee@0.4.X:
version "0.4.12"
resolved "http://npm.yohops.com/memoizee/-/memoizee-0.4.12.tgz#780e99a219c50c549be6d0fc61765080975c58fb"
...
...
@@ -4888,10 +4894,6 @@ memoizee@0.4.X:
next-tick "1"
timers-ext "^0.1.2"
memory-cache@^0.1.6:
version "0.1.6"
resolved "http://npm.yohops.com/memory-cache/-/memory-cache-0.1.6.tgz#2ed9933ed7a8c718249be7366f7ca8749acf8a24"
memory-fs@^0.2.0:
version "0.2.0"
resolved "http://npm.yohops.com/memory-fs/-/memory-fs-0.2.0.tgz#f2bb25368bc121e391c2520de92969caee0a0290"
...
...
@@ -5858,6 +5860,10 @@ pidusage-fork@^0.1.1:
version "0.1.2"
resolved "http://npm.yohops.com/pidusage-fork/-/pidusage-fork-0.1.2.tgz#a60c26d054e105cdb13243d083e81c7de8c1eef5"
pidusage@^1.1.6:
version "1.2.0"
resolved "http://npm.yohops.com/pidusage/-/pidusage-1.2.0.tgz#65ee96ace4e08a4cd3f9240996c85b367171ee92"
pify@^2.0.0, pify@^2.3.0:
version "2.3.0"
resolved "http://npm.yohops.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
...
...
@@ -6975,6 +6981,22 @@ redent@^2.0.0:
indent-string "^3.0.0"
strip-indent "^2.0.0"
redis-commands@^1.2.0:
version "1.3.5"
resolved "http://npm.yohops.com/redis-commands/-/redis-commands-1.3.5.tgz#4495889414f1e886261180b1442e7295602d83a2"
redis-parser@^2.6.0:
version "2.6.0"
resolved "http://npm.yohops.com/redis-parser/-/redis-parser-2.6.0.tgz#52ed09dacac108f1a631c07e9b69941e7a19504b"
redis@^2.1.0, redis@^2.8.0:
version "2.8.0"
resolved "http://npm.yohops.com/redis/-/redis-2.8.0.tgz#202288e3f58c49f6079d97af7a10e1303ae14b02"
dependencies:
double-ended-queue "^2.1.0-0"
redis-commands "^1.2.0"
redis-parser "^2.6.0"
reduce-css-calc@^1.2.6:
version "1.3.0"
resolved "http://npm.yohops.com/reduce-css-calc/-/reduce-css-calc-1.3.0.tgz#747c914e049614a4c9cfbba629871ad1d2927716"
...
...
@@ -7167,7 +7189,7 @@ request@2.81.0:
tunnel-agent "^0.6.0"
uuid "^3.0.0"
request@^2.34, request@^2.44.0, request@^2.73.0:
request@^2.34, request@^2.44.0, request@^2.73.0
, request@^2.81.0, request@^2.83.0
:
version "2.85.0"
resolved "http://npm.yohops.com/request/-/request-2.85.0.tgz#5a03615a47c61420b3eb99b7dba204f83603e1fa"
dependencies:
...
...
@@ -7279,10 +7301,6 @@ ret@~0.1.10:
version "0.1.15"
resolved "http://npm.yohops.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
retry@0.6.0:
version "0.6.0"
resolved "http://npm.yohops.com/retry/-/retry-0.6.0.tgz#1c010713279a6fd1e8def28af0c3ff1871caa537"
rewire@^2.5.1:
version "2.5.2"
resolved "http://npm.yohops.com/rewire/-/rewire-2.5.2.tgz#6427de7b7feefa7d36401507eb64a5385bc58dc7"
...
...
@@ -7492,10 +7510,6 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "http://npm.yohops.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
simple-lru-cache@0.0.x:
version "0.0.2"
resolved "http://npm.yohops.com/simple-lru-cache/-/simple-lru-cache-0.0.2.tgz#d59cc3a193c1a5d0320f84ee732f6e4713e511dd"
slash@^1.0.0:
version "1.0.0"
resolved "http://npm.yohops.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
...
...
@@ -8874,7 +8888,7 @@ winston-daily-rotate-file@^1.1.1, winston-daily-rotate-file@^1.1.4:
dependencies:
mkdirp "0.5.1"
winston@^2.2.0:
winston@^2.2.0
, winston@^2.4.0
:
version "2.4.1"
resolved "http://npm.yohops.com/winston/-/winston-2.4.1.tgz#a3a9265105564263c6785b4583b8c8aca26fded6"
dependencies:
...
...
@@ -9109,20 +9123,23 @@ yoho-json2@^1.0.0:
version "1.0.0"
resolved "http://npm.yohops.com/yoho-json2/-/yoho-json2-1.0.0.tgz#20c4b4f483498c939cd09e40260f09e7e257a04c"
yoho-node-lib@0.2.22:
version "0.2.22"
resolved "http://npm.yohops.com/yoho-node-lib/-/yoho-node-lib-0.2.22.tgz#85cdfd4e10a87bbcf892c26c7c9f54ad1bc95307"
yoho-node-lib@=0.6.6:
version "0.6.6"
resolved "http://npm.yohops.com/yoho-node-lib/-/yoho-node-lib-0.6.6.tgz#2c727bed970d8829730ac077bd379aa506db16f3"
dependencies:
bluebird "^3.4.0
"
dnscache "^1.0.1
"
handlebars "^4.0.5"
influx-batch-sender "^0.1.5"
lodash "^4.13.1"
lru-cache "^4.1.1"
md5 "^2.1.0"
memcached "^2.2.2"
memory-cache "^0.1.6"
moment "^2.13.0"
request-promise "^3.0.0"
pidusage "^1.1.6"
redis "^2.8.0"
request "^2.81.0"
uuid "^3.0.1"
walk "^2.3.9"
winston "^2.
2
.0"
winston "^2.
4
.0"
winston-daily-rotate-file "^1.1.1"
xss-filters "^1.2.6"
...
...
Please
register
or
login
to post a comment