V 2.03 Noch ein paar Anpassungen

This commit is contained in:
2026-04-01 14:14:15 +02:00
parent 6d1d60a9c1
commit 96a54b69d2
8 changed files with 77 additions and 37 deletions

4
.vscode/launch.json vendored
View File

@@ -14,8 +14,8 @@
"program": "${workspaceFolder}/fetchnewdata.js", "program": "${workspaceFolder}/fetchnewdata.js",
"args": [], "args": [],
"env": { "env": {
"MONGOPORT": "27098", "MONGOPORT": "27017",
"TYP": "['noise', 'thp']" "TYP": "['radioactivity', 'thp']"
} }
} }
] ]

View File

@@ -1,19 +1,59 @@
# Deploy Sensor-Files via esprimo und docker.citysensor.de #!/bin/bash
# 2023-12-17 rxf
#
# set -x # Deploy Script für werte-next
# Baut das Docker Image und lädt es zu docker.citysensor.de hoch
LINUX='esprimo' set -e
path="/home/rxf/Projekte/Sensors"
name=readin
rsync -avn --exclude=node_modules --exclude=.git --exclude=deploy.sh --exclude=TRANSFERE --exclude=INFLUXSERVER --exclude=data --exclude=log --exclude=.idea --exclude=.vscode --exclude=docs ./ $LINUX:$path/$name # Konfiguration
exit 0 REGISTRY="docker.citysensor.de"
IMAGE_NAME="readin"
TAG="${1:-latest}" # Erster Parameter oder "latest"
FULL_IMAGE="${REGISTRY}/${IMAGE_NAME}:${TAG}"
ssh $LINUX "cd $path/$name; # Build-Datum
./build_and_copy.sh localhost; BUILD_DATE=$(date +%d.%m.%Y)
docker tag $name docker.citysensor.de/$name;
docker push docker.citysensor.de/$name;"
exit 0 echo "=========================================="
echo "Werte-Next Deploy Script"
echo "=========================================="
echo "Registry: ${REGISTRY}"
echo "Image: ${IMAGE_NAME}"
echo "Tag: ${TAG}"
echo "Build-Datum: ${BUILD_DATE}"
echo "=========================================="
echo ""
# 1. Login zur Registry (falls noch nicht eingeloggt)
echo ">>> Login zu ${REGISTRY}..."
docker login "${REGISTRY}"
echo ""
# 2. Multiplatform Builder einrichten (docker-container driver erforderlich)
echo ">>> Richte Multiplatform Builder ein..."
if ! docker buildx inspect multiplatform-builder &>/dev/null; then
docker buildx create --name multiplatform-builder --driver docker-container --bootstrap
fi
docker buildx use multiplatform-builder
echo ""
# 3. Docker Image bauen und pushen (Multiplatform)
echo ">>> Baue Multiplatform Docker Image und pushe zu Registry..."
docker buildx build \
--platform linux/amd64,linux/arm64 \
--build-arg BUILD_DATE="${BUILD_DATE}" \
-t "${FULL_IMAGE}" \
--push \
.
echo ">>> Build und Push erfolgreich!"
echo ""
echo "=========================================="
echo "✓ Deploy erfolgreich abgeschlossen!"
echo "=========================================="
echo ""
echo "Auf dem Server ausführen:"
echo " docker pull ${FULL_IMAGE}"
echo " docker-compose -f docker-compose.prod.yml up -d"
echo ""

View File

@@ -5,20 +5,20 @@ volumes:
influx_vol: influx_vol:
services: services:
timeseries: # timeseries:
image: timeseries # image: timeseries
environment: # environment:
DEVELOP: "true" # DEVELOP: "true"
MONGOHOST: mongodb # MONGOHOST: mongodb
MONGOUSRP: "rexfue:noise4mongo" # MONGOUSRP: "rexfue:noise4mongo"
MONGOAUTH: "true" # MONGOAUTH: "true"
INFLUXHOST: influxdb # INFLUXHOST: influxdb
INFLUXTOKEN: "q35XUBaElzcy8dDd9HF2_mpeHvYCampZg_9mJNP5jeBQRopq3EWIzNTZ555QLSIXhZC05RXCoFgjiaT7VzyNkQ==" # INFLUXTOKEN: "q35XUBaElzcy8dDd9HF2_mpeHvYCampZg_9mJNP5jeBQRopq3EWIzNTZ555QLSIXhZC05RXCoFgjiaT7VzyNkQ=="
TYP: "[\"noise\", \"thp\"]" # TYP: "[\"noise\", \"thp\"]"
volumes: # volumes:
- ${PWD}/log:/var/log # - ${PWD}/log:/var/log
container_name: timeseries # container_name: timeseries
restart: unless-stopped # restart: unless-stopped
mongodb: mongodb:
image: mongo:6 image: mongo:6

View File

@@ -24,7 +24,7 @@ import { logit, logerror } from './logit.js'
import { DateTime } from 'luxon' import { DateTime } from 'luxon'
import fs from 'fs' import fs from 'fs'
import mod_getopt from 'posix-getopt' import mod_getopt from 'posix-getopt'
import pkg from './package.json' assert { type: "json" } const pkg = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf8'))
// import nodeSchedule from 'node-schedule' // import nodeSchedule from 'node-schedule'
@@ -76,7 +76,7 @@ const fetchNewData = async (args) => {
function parse_cmdline(argv) { function parse_cmdline(argv) {
let parser = new mod_getopt.BasicParser('i(influx)m(mongo)t:(typ)h(help)v(version)',argv); let parser = new mod_getopt.BasicParser('i(influx)m(mongo)t:(typ)h(help)v(version)',argv);
let option; let option;
let ret = {influx: true, mongo: true, typ: TYP} let ret = {influx: false, mongo: true, typ: TYP}
while((option = parser.getopt()) !== undefined) { while((option = parser.getopt()) !== undefined) {
switch(option.option) { switch(option.option) {
case 'i': case 'i':

View File

@@ -1,4 +1,4 @@
/* Interface for MongoDB /* Interface for MongoDB
*/ */
import { MongoClient } from 'mongodb' import { MongoClient } from 'mongodb'
import { logit, logerror } from './logit.js' import { logit, logerror } from './logit.js'

View File

@@ -1,7 +1,7 @@
{ {
"name": "timeseries_mongo", "name": "readin",
"version": "2.0.2", "version": "2.0.3",
"date": "2023-12-17", "date": "2026-04-01",
"description": "", "description": "",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {

View File

@@ -168,7 +168,7 @@ export const constructDBaseEntries = async (client, body, args) => {
pm: [], thp: [], noise: [], radioactivity: [], gps: [], unknown: [] pm: [], thp: [], noise: [], radioactivity: [], gps: [], unknown: []
} }
let datalines = '' let datalines = ''
actualProps = await mongo.getallProperties(client) // actualProps = await mongo.getallProperties(client)
try { try {
for (let item of body) { // check all entries for (let item of body) { // check all entries
const dt = item.timestamp.split(' ') const dt = item.timestamp.split(' ')