]>
Commit | Line | Data |
---|---|---|
67b718d4 BB |
1 | #!/usr/bin/env node |
2 | ||
3 | 'use strict'; | |
4 | ||
5 | /* eslint no-console: 0 */ | |
6 | ||
7 | const Path = require('path'); | |
8 | const Getenv = require('getenv'); | |
9 | ||
10 | const TomatoSauce = require('..'); | |
11 | const Util = require('../lib/util'); | |
12 | ||
13 | const config = { | |
a0666be3 RBR |
14 | port: Getenv.int('TOMATO_SAUCE_PORT', 9999), |
15 | frequency: Getenv.int('TOMATO_SAUCE_FREQUENCY', 333), | |
16 | modulation: Getenv.int('TOMATO_SAUCE_MODULATION_SPEED', 5) | |
67b718d4 BB |
17 | }; |
18 | ||
19 | const screenPath = Getenv('TOMATO_SAUCE_SCREEN_PATH', Path.join(__dirname, '../lib/screens')); | |
20 | const rendererPath = Getenv('TOMATO_SAUCE_RENDERER_PATH', Path.join(__dirname, '../lib/renderers')); | |
21 | ||
fd38d409 RBR |
22 | Util.loadFiles(screenPath).then((screens) => { |
23 | ||
a0666be3 RBR |
24 | config.screens = screens; |
25 | return Util.loadFiles(rendererPath); | |
fd38d409 | 26 | }) |
a0666be3 | 27 | .then((renderers) => { |
67b718d4 | 28 | |
a0666be3 RBR |
29 | config.renderers = renderers; |
30 | }) | |
31 | .then(() => { | |
fd38d409 | 32 | |
a0666be3 | 33 | const tomatoSauce = new TomatoSauce(config); |
fd38d409 | 34 | |
a0666be3 | 35 | tomatoSauce.on('listening', (event) => { |
67b718d4 | 36 | |
a0666be3 RBR |
37 | const address = event.data.server.address(); |
38 | console.log(`Tomato Sauce listening on: ${address.address}:${address.port}`); | |
39 | }); | |
fd38d409 | 40 | |
a0666be3 | 41 | tomatoSauce.on('error', (error) => { |
fd38d409 | 42 | |
a0666be3 RBR |
43 | console.error(error.stack || error.message || error); |
44 | process.exit(1); | |
45 | }); | |
fd38d409 | 46 | |
a0666be3 RBR |
47 | tomatoSauce.run(); |
48 | }); |