]> git.r.bdr.sh - rbdr/tomato-sauce/blame - bin/tomato_sauce.js
Merge branch 'feature/the-actual-tomato-sauce' into develop
[rbdr/tomato-sauce] / bin / tomato_sauce.js
CommitLineData
67b718d4
BB
1#!/usr/bin/env node
2
3'use strict';
4
5/* eslint no-console: 0 */
6
7const Path = require('path');
8const Getenv = require('getenv');
9
10const TomatoSauce = require('..');
11const Util = require('../lib/util');
12
13const config = {
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)
17};
18
19const screenPath = Getenv('TOMATO_SAUCE_SCREEN_PATH', Path.join(__dirname, '../lib/screens'));
20const rendererPath = Getenv('TOMATO_SAUCE_RENDERER_PATH', Path.join(__dirname, '../lib/renderers'));
21
22Util.loadFiles(screenPath).then(function (screens) {
23 config.screens = screens;
24 return Util.loadFiles(rendererPath);
25}).then(function (renderers) {
26 config.renderers = renderers;
27}).then(function () {
28 let tomatoSauce = new TomatoSauce(config);
29
30 tomatoSauce.on('listening', function (event) {
31 const address = event.data.server.address();
32 console.log(`Tomato Sauce listening on: ${address.address}:${address.port}`);
33 });
34
35 tomatoSauce.on('error', function (error) {
36 console.error(error.stack || error.message || error);
37 process.exit(1);
38 });
39
40 tomatoSauce.run();
41});