-
-
Save creationix/f2ca3b8c99131926f577 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local http = require("http") | |
local https = require("https") | |
local pathJoin = require('luvi').path.join | |
local fs = require('fs') | |
local timer = require('timer') | |
local snapshot = require('snapshot') | |
local S1 | |
local i = 0 | |
local function onRequest(req, res) | |
--print(req.socket.options and "https" or "http", req.method, req.url) | |
local body = "Hello world\n" | |
res:setHeader("Content-Type", "text/plain") | |
res:setHeader("Content-Length", #body) | |
res:finish(body) | |
collectgarbage() | |
timer.setTimeout(100, function () | |
collectgarbage() | |
local S2 = snapshot() | |
print("Start " .. i) | |
local c = 0 | |
for k,v in pairs(S2) do | |
if S1[k] == nil then | |
c = c + 1 | |
p(k) | |
print(v) | |
end | |
end | |
S1 = S2 | |
print("end " .. i .. "(" .. c .. ")") | |
i = i + 1 | |
end) | |
end | |
http.createServer(onRequest):listen(8080) | |
print("Server listening at http://localhost:8080/") | |
https.createServer({ | |
key = fs.readFileSync(pathJoin(module.dir, "key.pem")), | |
cert = fs.readFileSync(pathJoin(module.dir, "cert.pem")), | |
}, onRequest):listen(8443) | |
print("Server listening at https://localhost:8443/") | |
collectgarbage() | |
S1 = snapshot() |
Author
creationix
commented
Oct 29, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment