forked from nodebeats/nodebeats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
46 lines (36 loc) · 937 Bytes
/
server.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
'use strict';
var http = require('http'),
app = require('./app'),
server = http.createServer(app),
port = process.env.PORT || 3000;
/**
* Define the application.
*/
var NodeBeats = function() {
// Scope.
var self = this;
/**
* Set up server IP address and port # using env variables/defaults.
*/
self.setupVariables = function() {
self.port = port;
};
/**
* Start the server
*/
self.start = function() {
// Start the app on the specific interface (and port).
server.listen(self.port, function() {
console.log('Node server started on ' + self.port + ' at ' + Date(new Date()));
});
};
};
var nodeBeatApp = new NodeBeats();
nodeBeatApp.setupVariables();
nodeBeatApp.start();
process.on('SIGTERM', function () {
server.close(function () {
process.exit(0);
});
});
module.exports = server;