Compare commits
No commits in common. 'master' and 'release-2.0' have entirely different histories.
master
...
release-2.
@ -1,28 +1,18 @@
|
||||
# ---- Base ----
|
||||
FROM alpine:3 AS base
|
||||
FROM node:16-alpine
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copy project file
|
||||
COPY package.json .
|
||||
|
||||
# Install required apk-packages
|
||||
RUN apk add --no-cache nodejs npm tcpdump
|
||||
|
||||
|
||||
# ---- Dependencies ----
|
||||
FROM base AS dependencies
|
||||
|
||||
# Install app dependencies
|
||||
RUN npm install --only=production
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
# remove development dependencies
|
||||
RUN npm prune --production
|
||||
|
||||
# ---- Release ----
|
||||
FROM base AS release
|
||||
# Install required apk-packages & delete cache
|
||||
RUN apk update && apk add tcpdump && rm -rf /var/cache/apk/*
|
||||
|
||||
# copy from build image
|
||||
COPY --from=dependencies /usr/src/app/ ./
|
||||
# Bundle app source
|
||||
COPY ./src/ .
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
TAG="ruakij/rfmon-to-influx"
|
||||
PLATFORM="linux/amd64,linux/arm64/v8,linux/arm/v7"
|
||||
EXTRA_ARGS="$@"
|
||||
|
||||
docker buildx build \
|
||||
--platform $PLATFORM \
|
||||
--tag $TAG \
|
||||
$EXTRA_ARGS \
|
||||
.
|
@ -1,7 +0,0 @@
|
||||
TAG="ruakij/rfmon-to-influx"
|
||||
EXTRA_ARGS="$@"
|
||||
|
||||
docker build \
|
||||
--tag $TAG \
|
||||
$EXTRA_ARGS \
|
||||
.
|
Binary file not shown.
Before Width: | Height: | Size: 147 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
@ -1,72 +0,0 @@
|
||||
const logger = require.main.require("./helper/logger.js")("InfluxDbLineProtocolWriter");
|
||||
const net = require("net");
|
||||
|
||||
/**
|
||||
* Get points and write them into influx
|
||||
*/
|
||||
class InfluxDbLineProtocolWriter extends net.Socket{
|
||||
/**
|
||||
*
|
||||
* @param {string} host Host of line-server
|
||||
* @param {string} port Port of line-server
|
||||
* @param {object} options Options for further configuration
|
||||
*/
|
||||
constructor(host, port, options = {}) {
|
||||
super();
|
||||
|
||||
this._host = host;
|
||||
this._port = port;
|
||||
|
||||
// options defaults
|
||||
options.autoConnect ??= true;
|
||||
options.timeout ??= 5000;
|
||||
options.autoReconnect ??= true;
|
||||
options.autoReconnectBackoffTime ??= 3000;
|
||||
this._options = options;
|
||||
|
||||
this._isConnected = false;
|
||||
|
||||
super.setKeepAlive(true, 5000);
|
||||
|
||||
// Register auto-Reconnect if enabled
|
||||
if(this._options.autoReconnect){
|
||||
this.on("connect", () => {
|
||||
logger.debug("Connection established!");
|
||||
this._isConnected = true;
|
||||
|
||||
if(this._autoReconnectTimeout)
|
||||
clearInterval(this._autoReconnectTimeout);
|
||||
this._autoReconnectTimeout = 0;
|
||||
});
|
||||
|
||||
this.on("error", (err) => {
|
||||
logger.error(err.code, "TCP ERROR");
|
||||
this._isConnected = false;
|
||||
|
||||
if(!this._autoReconnectTimeout)
|
||||
this._autoReconnectTimeout = setInterval(() => {
|
||||
this.connect();
|
||||
},
|
||||
this._options.autoReconnectBackoffTime);
|
||||
});
|
||||
}
|
||||
|
||||
// Autoconnect if requested
|
||||
if(this._options.autoConnect) this.connect();
|
||||
}
|
||||
|
||||
get host(){ return this._host; }
|
||||
get port(){ return this._port; }
|
||||
|
||||
get isConnected(){ return this._isConnected; }
|
||||
|
||||
connect(){
|
||||
logger.debug("Connecting..");
|
||||
super.connect(this._port, this._host);
|
||||
}
|
||||
}
|
||||
|
||||
// Specify exports
|
||||
module.exports = {
|
||||
InfluxDbLineProtocolWriter
|
||||
};
|
@ -1,22 +0,0 @@
|
||||
const logger = require.main.require("./helper/logger.js")("InfluxPointToLineProtoStream");
|
||||
const { Transform } = require("stream");
|
||||
|
||||
/**
|
||||
* Get points and converts them to Line-protocol
|
||||
*/
|
||||
class InfluxPointToLineProtoStream extends Transform{
|
||||
constructor(){
|
||||
super({
|
||||
writableObjectMode: true
|
||||
});
|
||||
}
|
||||
|
||||
_transform(point, encoding, next){
|
||||
next(null, point.toLineProtocol() +"\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Specify exports
|
||||
module.exports = {
|
||||
InfluxPointToLineProtoStream
|
||||
};
|
Loading…
Reference in New Issue