Created
November 5, 2012 17:27
-
-
Save thattommyhall/4018587 to your computer and use it in GitHub Desktop.
testing new static assets server
This file contains hidden or 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
| 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