shichao-an / soundmeter

Simple real-time sound meter
https://soundmeter.shichao.io
BSD 2-Clause "Simplified" License
82 stars 27 forks source link

Daemon Quits #26

Open PatrickNY opened 5 years ago

PatrickNY commented 5 years ago

I currently have the daemon running (soundmeter -d --segment 5 --log sound.csv) on a Raspberry Pi 3b. The program logs every 5 (or 4.9?) seconds to the log file. Great! However, I haven't gotten it to be able to run for more then a few hours at a time. I'd like it to run indefinitely.

My thoughts: I download the log file to my web server (I use my server to pull the file from my Pi using lftp sftp://user:pass@home-ip:1234 -e "get sound.csv; bye") periodically. It seems that it is at that time that the soundmeter daemon quits. There is no log showing any errors that I can find. (/var/log - messages, syslog, error, etc.)

I'm guessing that when I pull the file, soundmeter cannot access the log to write the new data and it quits.

My thoughts were to quick copy the file on the Pi (cp sound.csv sound1.csv), and then download that new file via sftp, but I think even that stopped soundmeter from logging!

Question: Am I correct in thinking that this is why the program quits? (Because I am accessing the log file when it might be trying to write to it?) Can you think of any solutions that might work? Is there a way that the program can debug this for me and show me a log as to why it quits?

(My next plan .. set up a cron job to run the logger for 6 hours with the --seconds 21600 switch, download the log file at that time, delete the log file and start the daemon again .. but that seems to be a little overkill)

Great program -- I'm having fun experimenting with it!

PatrickNY commented 5 years ago

Update: I was incorrect to assume that "When I pull the file via sftp, soundmeter cannot access the log to write the new data and it quits." It actually seems that the daemon quits quite randomly. Sometimes, it quits 5 times within a 6 hour period, sometimes it doesn't quit at all in a 6 hour period. I 'put' the file once every 6 hours onto my web server where I can further analyze it, but due to the fact that the program stops recording data while it is restarting, there are holes in the data stream.

Is there any way to debug the program to show the cause of why it stops running?

shichao-an commented 5 years ago

Not sure what's the exact cause without logs. I suggest you can do:

PatrickNY commented 5 years ago

Thank you for your detailed response. The next time the program crashes, I'll use a process manager to run the program.

Guess what, though .. It hasn't crashed in a few days! I found a suggestion on a closed ticket in this forum that suggested that I lower the sampling rate from 48000 to 16000. I think that did the trick!

Thanks again for your great program!