diff options
| author | Ben Beltran <ben@nsovocal.com> | 2016-05-09 00:31:52 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2016-05-09 00:31:52 -0500 |
| commit | a41763dd463339765081c1f968a7b93b8ccf572f (patch) | |
| tree | 131f33520cc40abc387474fa9c2ac4f536e6d7d1 /bin | |
| parent | 95da493e0ec223e1c7706fc0bdc364bd3a21d999 (diff) | |
| parent | a140f3add912ef4bd659c1c1e82184643be7d845 (diff) | |
Merge branch 'release/1.0.0'
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/tomato_sauce.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/tomato_sauce.js b/bin/tomato_sauce.js new file mode 100755 index 0000000..5a416d5 --- /dev/null +++ b/bin/tomato_sauce.js @@ -0,0 +1,41 @@ +#!/usr/bin/env node + +'use strict'; + +/* eslint no-console: 0 */ + +const Path = require('path'); +const Getenv = require('getenv'); + +const TomatoSauce = require('..'); +const Util = require('../lib/util'); + +const config = { + port: Getenv.int('TOMATO_SAUCE_PORT', 9999), + frequency: Getenv.int('TOMATO_SAUCE_FREQUENCY', 333), + modulation: Getenv.int('TOMATO_SAUCE_MODULATION_SPEED', 5) +}; + +const screenPath = Getenv('TOMATO_SAUCE_SCREEN_PATH', Path.join(__dirname, '../lib/screens')); +const rendererPath = Getenv('TOMATO_SAUCE_RENDERER_PATH', Path.join(__dirname, '../lib/renderers')); + +Util.loadFiles(screenPath).then(function (screens) { + config.screens = screens; + return Util.loadFiles(rendererPath); +}).then(function (renderers) { + config.renderers = renderers; +}).then(function () { + let tomatoSauce = new TomatoSauce(config); + + tomatoSauce.on('listening', function (event) { + const address = event.data.server.address(); + console.log(`Tomato Sauce listening on: ${address.address}:${address.port}`); + }); + + tomatoSauce.on('error', function (error) { + console.error(error.stack || error.message || error); + process.exit(1); + }); + + tomatoSauce.run(); +}); |