add toobusy 503 response

This commit is contained in:
jomo
2015-05-24 13:34:49 +02:00
parent 6f94af7a4a
commit e1f1fe7c57
2 changed files with 14 additions and 3 deletions

View File

@@ -1,7 +1,8 @@
#!/usr/bin/env node
var logging = require("./logging");
var querystring = require("querystring");
var response = require("./response");
var toobusy = require("toobusy-js");
var logging = require("./logging");
var config = require("./config");
var http = require("http");
var mime = require("mime");
@@ -65,6 +66,15 @@ function requestHandler(req, res) {
var local_path = req.url.path_list[0];
logging.log(req.id, req.method, req.url.href);
if (toobusy()) {
res.writeHead(503, {
"Content-Type": "text/plain"
});
res.end("Server is over capaacity :/");
return;
}
if (req.method === "GET" || req.method === "HEAD") {
try {
switch (local_path) {