fix memory leak
parent
f5864ef78e
commit
09a4c02312
|
@ -2,3 +2,4 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
config.json
|
config.json
|
||||||
|
dist/
|
12
gulpfile.js
12
gulpfile.js
|
@ -3,6 +3,7 @@ var coffeelint = require('gulp-coffeelint');
|
||||||
var nodemon = require('gulp-nodemon');
|
var nodemon = require('gulp-nodemon');
|
||||||
var plumber = require("gulp-plumber");
|
var plumber = require("gulp-plumber");
|
||||||
var cache = require("gulp-cache");
|
var cache = require("gulp-cache");
|
||||||
|
var coffee = require("gulp-coffee");
|
||||||
|
|
||||||
gulp.task('lint', function () {
|
gulp.task('lint', function () {
|
||||||
gulp.src(['**/*.coffee', '!node_modules/**/*'])
|
gulp.src(['**/*.coffee', '!node_modules/**/*'])
|
||||||
|
@ -19,6 +20,17 @@ gulp.task('lint', function () {
|
||||||
.pipe(coffeelint.reporter());
|
.pipe(coffeelint.reporter());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('config', function() {
|
||||||
|
return gulp.src('config.json')
|
||||||
|
.pipe(gulp.dest('dist/'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task("coffee", ['config'], function() {
|
||||||
|
return gulp.src("*.coffee")
|
||||||
|
.pipe(coffee())
|
||||||
|
.pipe(gulp.dest("dist/"));
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('develop', function () {
|
gulp.task('develop', function () {
|
||||||
nodemon({ script: 'index.coffee'})
|
nodemon({ script: 'index.coffee'})
|
||||||
.on('change', ['lint']);
|
.on('change', ['lint']);
|
||||||
|
|
|
@ -18,15 +18,16 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^3.8.11",
|
"gulp": "^3.8.11",
|
||||||
"gulp-cache": "^0.3.0",
|
"gulp-cache": "^0.3.0",
|
||||||
|
"gulp-coffee": "^2.3.3",
|
||||||
"gulp-coffeelint": "^0.5.0",
|
"gulp-coffeelint": "^0.5.0",
|
||||||
"gulp-nodemon": "^2.0.4",
|
"gulp-nodemon": "^2.0.4",
|
||||||
"gulp-plumber": "^1.0.1"
|
"gulp-plumber": "^1.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"amqplib": "^0.4.1",
|
"amqplib": "^0.5.1",
|
||||||
"base64-url": "^1.2.1",
|
"base64-url": "^1.2.1",
|
||||||
"bluebird": "^2.9.10",
|
"bluebird": "^2.9.10",
|
||||||
"node-uuid": "^1.4.2",
|
"node-uuid": "^1.4.2",
|
||||||
"ws": "^1.1.1"
|
"ws": "^2.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,6 @@ channels = do ->
|
||||||
return pendingChannels[client_id]
|
return pendingChannels[client_id]
|
||||||
|
|
||||||
pendingChannels[client_id] = new Promise (resolve, reject) ->
|
pendingChannels[client_id] = new Promise (resolve, reject) ->
|
||||||
delete pendingChannels[client_id]
|
|
||||||
|
|
||||||
if !chs[client_id]
|
if !chs[client_id]
|
||||||
getConnection()
|
getConnection()
|
||||||
.then (connection) -> connection.createChannel()
|
.then (connection) -> connection.createChannel()
|
||||||
|
@ -63,7 +61,10 @@ channels = do ->
|
||||||
else
|
else
|
||||||
resolve(chs[client_id])
|
resolve(chs[client_id])
|
||||||
|
|
||||||
return pendingChannels[client_id]
|
return pendingChannels[client_id].then (ch) ->
|
||||||
|
delete pendingChannels[client_id]
|
||||||
|
|
||||||
|
return ch
|
||||||
|
|
||||||
return {
|
return {
|
||||||
removeClient: removeClient
|
removeClient: removeClient
|
||||||
|
|
Loading…
Reference in New Issue