Comments (3)
There are multiple options
- Disable logging if there is not some specific need for logs. In case you would need them - can enable back later.
- Use logrotate functionality on QNAP, not sure if there is such, maybe there are some 3rd party packages that would enable such functionality.
- Write script that would do rotation - it should be possible to write scripts and schedule execution on QNAP?!
- Use specific container that would provide such functionality.
from wmbusmeters.
Thanks for your reply.
I thought I missed something, because it is mentioned in the documentation that make install
installs a. o. /etc/logrotate.d/wmbusmeters
. I expected that it is a matter of configuration to use logrote
in the docker environment as well.
I like docker because it reduces dependencies and complexity.
I want to avoid having additional dependencies/connections/relations to the wmbusmeters container from outside the container.
I looked into the wmbusmeters container with docker exec -it wmbusmeters sh
and realized that logrotate
is not part of it.
cat /etc/os-release
gave me Alpine Linux v3.14
.
With
apk update
apk upgrade
apk add logrotate
I added logrotate
to the container.
I created a /wmbusmeters_data/etc/logrotate.conf
according to scripts/prepare_logfiles.sh:
cat /wmbusmeters_data/etc/logrotate.conf
/wmbusmeters_data/logs/meter_readings/*
/wmbusmeters_data/logs/*.log {
su root root
rotate 12
daily
compress
missingok
postrotate
/usr/bin/killall -HUP /wmbusmeters/wmbusmeters
endscript
}
logrotate
needs a cron daemon.
The standard cron daemon appears to be not the best solution inside a docker container.
I decided to use supercronic and installed it with
export SUPERCRONIC_URL='https://github.com/aptible/supercronic/releases/download/v0.2.24/supercronic-linux-amd64'
export SUPERCRONIC='supercronic-linux-amd64'
export SUPERCRONIC_SHA1SUM='6817299e04457e5d6ec4809c72ee13a43e95ba41'
curl -fsSLO "$SUPERCRONIC_URL" \
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \
&& chmod +x "$SUPERCRONIC" \
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
I created a crontab for logrotate
:
cat /wmbusmeters_data/etc/supercronic_crontab
0 * * * * /usr/sbin/logrotate /wmbusmeters_data/etc/logrotate.conf --state /wmbusmeters_data/etc/logrotate-state
Finally I adjusted /wmbusmeters/docker-entrypoint.sh
to
#!/bin/sh
[ ! -d /wmbusmeters_data/logs/meter_readings ] && mkdir -p /wmbusmeters_data/logs/meter_readings
[ ! -d /wmbusmeters_data/etc/wmbusmeters.d ] && mkdir -p /wmbusmeters_data/etc/wmbusmeters.d
[ ! -f /wmbusmeters_data/etc/wmbusmeters.conf ] && echo -e "loglevel=normal\ndevice=auto:t1\ndonotprobe=/dev/ttyAMA0\nlogtelegrams=false\nformat=json\nmeterfiles=/wmbusmeters_data/logs/meter_readings\nmeterfilesaction=overwrite\nlogfile=/wmbusmeters_data/logs/wmbusmeters.log" > /wmbusmeters_data/etc/wmbusmeters.conf
/usr/local/bin/supercronic /wmbusmeters_data/etc/supercronic_crontab &
/wmbusmeters/wmbusmeters --useconfig=/wmbusmeters_data
in oder to run the supercronic
cron daemon in the background.
This solution works for me.
I am aware that I will have an issue when I update the container from the repository - my changes will be lost.
Maybe the container maintainers decide to add logrotate
, logrotate.conf
, supercronic
, a supercronic_crontab
and an adjusted docker-entrypoint.sh
to the next wmbusmeters container version ;-)
from wmbusmeters.
I will close second opened issue regarding this topic - let`s keep discussion and tracking under one issue.
There is indeed logrotate configs included, but that all is for standalone version and was not included in docker. Another reason logrotate not being in docker is that IMO it is much simpler to manage logs from host side and leave docker only for app purposes, but I understand why this is issue for you. You have already done great job on making necessary changes and testing them so I do not see big issue if we would add it to container with few buts:
- Can you test if logrotate config is removed if it will not cause issues for docker functionality. Idea is - if someone would like to disable logrotate functionality withing docker, how it should be done correctly that does not compromise container functionality.
- I`m not fond of including some specific version of software in docker file - it would mean that constant followup and updates would be needed, It will make thing even more complex to build for multiple architectures.
supercronic is included as package starting from Alpline 3.15, so let`s give some time for multiarch/alpine repo to update their base image to more latest one and then we could implement this properly. If you notice this happening you are more then welcome to create PR, meanwhile I will mark this issue as planned.
Regarding your local changes - you can use wmbusmeters/wmbusmeters:release-1.13.1
docker image for example, if everything is working for you and you do not need latest changes, that way your local container would not be recreated and you would not lose local changes.
from wmbusmeters.
Related Issues (20)
- wmbusmeters: command not found
- Cannot decrypt this frame HOT 4
- Kamstrup Heat meter can't parse energy HOT 2
- Key extraction from Kamstrup Wireless MBus Dongle HOT 3
- Water 5.5 Qundis HOT 7
- Negative water flow direction is displayed incorrectly HOT 16
- Add support for mfct: (GWF) Gas u Wassermesserfabrik, Switzerland HOT 4
- Handle compressed telegrams HOT 3
- Some kamstrup compressed telegrams cannot be parsed. HOT 12
- Metersit G4 support (169 MHz Gas Meter with AMB3665) HOT 3
- Support for water meters in Narrow Band HOT 2
- No Telegrams. HOT 2
- Device Support for "(IMT) INTEGRA METERING, Switzerland (0x25b4) type: Bus/System component (0x0e) ver: 0x05" HOT 5
- Add new device- (ALK) Actislink, Poland (0x58b), type: Water meter (0x07) ver: 0x04 HOT 1
- not detecting right driver HOT 4
- Support of RTL-SDR V4 Dongle and its drivers HOT 2
- Please add sonometer danfoss 1000 and 11000
- Can the meter readings be used for the official utility bill? HOT 3
- Missing File pollucomf.json HOT 3
- Izar driver problem with short PRIOS payload (L=0x13) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wmbusmeters.