Fix session memory leak
This commit is contained in:
parent
0289bddde8
commit
046d8475cb
6 changed files with 62 additions and 32 deletions
12
web/app.js
12
web/app.js
|
@ -3,9 +3,7 @@ import Router from 'koa-router';
|
|||
import csrf from 'koa-csrf';
|
||||
import views from 'koa-views';
|
||||
import stats from 'koa-statsd';
|
||||
import redis from '../lib/redis';
|
||||
import koaRedis from 'koa-redis'
|
||||
import session from 'koa-generic-session';
|
||||
import * as redis from '../lib/redis';
|
||||
import co from 'co';
|
||||
import StatsD from 'statsy';
|
||||
// waiting for PR to be merged, can remove swig dependency when done
|
||||
|
@ -22,18 +20,16 @@ const router = new Router();
|
|||
router.use(errors({template: path.join(__dirname, 'public', '404.html')}));
|
||||
|
||||
let statsdOpts = {prefix: 'hostr-web', host: process.env.STATSD_HOST || 'localhost'};
|
||||
router.use(stats(statsdOpts));
|
||||
let statsd = new StatsD(statsdOpts);
|
||||
router.use(function* (next) {
|
||||
this.statsd = statsd;
|
||||
yield next;
|
||||
});
|
||||
router.use(stats(statsdOpts));
|
||||
|
||||
router.use(session({
|
||||
store: koaRedis({client: redis().client})
|
||||
}));
|
||||
router.use(redis.sessionStore());
|
||||
|
||||
router.use(function* (next){
|
||||
router.use(function* (next) {
|
||||
this.state = {
|
||||
session: this.session,
|
||||
apiURL: process.env.API_URL,
|
||||
|
|
|
@ -45,7 +45,7 @@ export function* get() {
|
|||
localPath = path.join(storePath, file._id[0], this.params.size, file._id + '_' + file.file_name);
|
||||
remotePath = path.join(this.params.size, file._id + '_' + file.file_name);
|
||||
}
|
||||
console.log(localPath);
|
||||
|
||||
if (file.malware) {
|
||||
this.statsd.incr('file.malware.download', 1);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ export function* landing() {
|
|||
this.params.name = file.file_name;
|
||||
return yield get.call(this);
|
||||
}
|
||||
console.log('incr')
|
||||
|
||||
this.statsd.incr('file.landing', 1);
|
||||
const formattedFile = formatFile(file);
|
||||
yield this.render('file', {file: formattedFile});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue