-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (33 loc) · 1.01 KB
/
index.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
43
44
45
46
47
/* NodeJS EIDA Federator Prototype
*
* Federates dataselect and station requests across EIDA
* THIS IS AN EARLY PROTOTYPE AND EXPERIMENT
*
* Author: Mathijs Koymans, 2018
* Copyright: ORFEUS Data Center
* License: MIT
*
*/
"use strict";
// Globally patch the require function
require("./require");
const { createServer } = require("http");
const { server } = require("./lib/federator");
module.exports = function(port, host, listenCallback) {
// Disable timeouts
const FEDERATOR_TIMEOUT_MS = 0;
// Create the federator server
const federator = createServer(server);
// Replace with ENV variables
port = process.env.SERVICE_PORT || port;
host = process.env.SERVICE_HOST || host;
federator.timeout = FEDERATOR_TIMEOUT_MS;
// Open for incoming connections
federator.listen(port, host, listenCallback);
}
if(require.main === module) {
const CONFIG = require("./config");
new module.exports(CONFIG.PORT, CONFIG.HOST, function() {
console.log("EIDA Federator has been initialized.");
});
}