From 5d5cdddaaeb395807b26b59bc9f3d5e2d4c3b41c Mon Sep 17 00:00:00 2001 From: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Date: Thu, 27 May 2021 18:12:37 +0200 Subject: [PATCH] fix: Try fixing Raspberry Pi docker image --- Dockerfile | 2 +- bin/run | 2 +- example/extend-app.js | 23 +++++++++++++++++++++++ src/index.ts | 4 ++-- 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 example/extend-app.js diff --git a/Dockerfile b/Dockerfile index c846439..8363241 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:current-alpine as node-original +FROM node:14-alpine as node-original FROM node-original as install WORKDIR /usr/src/app COPY package*.json ./ diff --git a/bin/run b/bin/run index 888b5c8..0a34ddf 100644 --- a/bin/run +++ b/bin/run @@ -1,6 +1,6 @@ #!/usr/bin/env node -const Smartmeter = require('../dist/index.js').Smartmeter; +const Smartmeter = require('../dist/index').Smartmeter; const smartmeter = new Smartmeter(); smartmeter.start(); diff --git a/example/extend-app.js b/example/extend-app.js new file mode 100644 index 0000000..c727e38 --- /dev/null +++ b/example/extend-app.js @@ -0,0 +1,23 @@ + +const Smartmeter = require('../dist/index').Smartmeter; +const ConfigLoader = require('../dist/index').ConfigLoader; + +const config = ConfigLoader.Load(); + +// Change something to the config +//config.outputs.debug = true; + +const smartmeter = new Smartmeter(config); + +// Add your custom output +// const newOutput = new xxx() // As long as it implements Output +// smartmeter.addOutput(newOutput); + +smartmeter.start(); + +// Listen for exit signal and cleanly shutdown +process.on('SIGINT', async () => { + console.log('Exiting....'); + await smartmeter.stop(); + process.exit(0); +}); diff --git a/src/index.ts b/src/index.ts index 3032fe4..80374f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,9 +3,9 @@ import P1Map from './p1-map'; import { DecryptionResult, P1Crypt } from './p1-crypt'; import { Output } from './output/output'; import IntervalOutput from './output/interval-output'; -import { SmartmeterConfig } from './config'; +import { SmartmeterConfig, ConfigLoader } from './config'; import Smartmeter from './smartmeter'; export { - DsmrMessage, P1Crypt, DecryptionResult, P1Map, Output, IntervalOutput, SmartmeterConfig, Smartmeter, + DsmrMessage, P1Crypt, DecryptionResult, P1Map, Output, IntervalOutput, SmartmeterConfig, ConfigLoader, Smartmeter, };