28 lines
676 B
JavaScript
28 lines
676 B
JavaScript
// requirements
|
|
const blinkstick = require('./libs/blinkstick');
|
|
const server = require('./libs/server');
|
|
const logger = require('./libs/logger');
|
|
const packageJSON = require('./package');
|
|
|
|
// start the application
|
|
main();
|
|
|
|
// main - let's get this party started
|
|
function main() {
|
|
server.start()
|
|
.then(logger.info)
|
|
.then(server.handleRequests)
|
|
.catch(exit);
|
|
}
|
|
|
|
// ... and it all comes crashing down
|
|
function exit(err) {
|
|
let code = 0;
|
|
if (err) {
|
|
logger.error(err);
|
|
logger.error(packageJSON.name + " ended due to an error");
|
|
} else {
|
|
logger.info(packageJSON.name + " shutting down gracefully")
|
|
}
|
|
process.exit(code);
|
|
}
|