Skip to content

Instantly share code, notes, and snippets.

@thattommyhall
Created November 5, 2012 17:27
Show Gist options
  • Select an option

  • Save thattommyhall/4018587 to your computer and use it in GitHub Desktop.

Select an option

Save thattommyhall/4018587 to your computer and use it in GitHub Desktop.
testing new static assets server
lazy = require 'lazy'
http = require 'http'
http.globalAgent.maxSockets = 200
process.stdin.resume()
failed = 0
success = 0
status = ->
console.log
failed: failed
success: success
setInterval status, 10000
input = new lazy(process.stdin)
input.lines
.map(String)
.forEach (line) ->
match = line.match /"GET (.*?) HTTP\/1\.1"/
if match? and (line.match /\s2\d\d\s/ or line.match /\s3\d\d\s/)
path = match[1]
spec =
host:'static.coresites.mpora.com'
port:80
path:path
request = http.get spec , (res) ->
success++
unless (String res.statusCode).match /2\d\d/
console.log url
request.on 'error', (e) ->
console.log path
console.log("Got error: " + e.message)
failed++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment