Skip to content

Commit

Permalink
Rollback faulty keepalive prevention
Browse files Browse the repository at this point in the history
  • Loading branch information
coreybutler committed Apr 21, 2014
1 parent 8a300f3 commit 382205b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/lib/api/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,17 @@ var Server = Utility.extend({
value: false
},

/**
* @property {Boolean} stopping
* Indicates the server is stopping.
*/
stopping:{
enumerable: true,
writable: true,
configurable: false,
value: false
},

initialized:{
enumerable: false,
writable: true,
Expand Down Expand Up @@ -316,8 +327,6 @@ var Server = Utility.extend({

this._http = http.createServer(function(req,res){

req.setSocketKeepAlive(false,0);

// Custom directory handling logic:
function redirect() {
me.syslog.log('Redirect to '+req.url+'/');
Expand Down Expand Up @@ -721,18 +730,18 @@ var Server = Utility.extend({
* @fires stop
*/
stop: function(cb){
console.log("Stop()");
var me = this;
this.starting = false;
if (!this.running){
console.log('Not Running');
cb && cb();
return;
}
this.stopping = true;
if (this.shared){
this.unshare(function(){
me.http.close(function(){
me.running = false;
me.stopping = false;
/**
* @event stop
* Fired when the server is stopped. Sends the Server objects as a handler argument.
Expand All @@ -743,11 +752,10 @@ var Server = Utility.extend({
});
});
} else if (this.running){
console.log('Shutting down the running server...');
try {
this._http.once('close',function(){
console.log('Closed');
me.running = false;
me.stopping = false;
me.emit('stop',me);
me.syslog.log('Server stopped on port '+me.port.toString()+'.');
cb && cb();
Expand Down

0 comments on commit 382205b

Please sign in to comment.