function main(argv) {
  var httpPort = argv['http-port'];
  var storagePath = argv['path'];
  console.log('Launching trace server...');
  console.log('   http: ' + httpPort);
  console.log('   path: ' + storagePath);

  mkdirp.sync(storagePath);

  function handleGet(req, res, url) {
  res.writeHead(200, ['Content-Type', 'text/plain']);
    res.end('get');
  };

  function handlePost(req, res, url) {
    var filename = req.headers['x-filename'] || null;
    if (filename) {
      filename = path.basename(filename);
    } else {
      filename = 'trace.wtf-trace';
    }

    var filePath = path.join(storagePath, filename);
    var file = fs.createWriteStream(filePath);
    console.log('Writing trace to ' + filePath + '...');

    req.pipe(file);

    req.on('end', function() {
      console.log('Done!');

      res.writeHead(200, ['Content-Type', 'text/plain']);
      res.end('Done!');
    });
  };

  var httpServer = http.createServer(function(req, res) {
    var parsedUrl = url.parse(req.url, true);
    switch (req.method) {
      case 'GET':
        handleGet(req, res, url);
        break;
      case 'POST':
        handlePost(req, res, url);
        break;
      default:
        res.writeHead(405, ['Content-Type', 'text/plain']);
        res.end('Invalid Method');
        break;
    }
  });
  httpServer.listen(httpPort);

  console.log('Server ready, use ctrl-c to exit...');
  console.log('');
}
@fileoverview Trace storage server.
Accepts POSTs of trace files for saving to the local disk.

@author benvanik@google.com (Ben Vanik)