forked from YahooArchive/mockaccino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (35 loc) · 979 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env node
/* Copyright (c) 2015 Yahoo Inc. */
/*jshint node: true */
"use strict";
var parser = require('yargs'),
mockaccino = require('./server'),
mockresponses,
app,
cfgFile,
port,
maxSockets = 150,
http,
argv;
argv = parser.argv;
http = require('http');
http.globalAgent.maxSockets = maxSockets;
if (argv.help) {
console.log("Mockaccino help\n\n");
console.log("--config allows you to specify the config file");
console.log("--port allows you to specify which port mockaccino will be listening to");
console.log("--help shows this");
return;
}
cfgFile = argv.config;
if (cfgFile) {
mockresponses = require("./" + cfgFile);
} else {
throw "Usage: node app --config configFile [--port PORT]";
}
port = argv.port || 8081;
app = mockaccino(mockresponses);
//if it's running stand alone
http.createServer(app).listen(port, function () {
console.log('[Mockaccino] listening on port ' + port);
});