Closed nowcodingaway closed 1 week ago
I now realise that if you are using polling, CRON is likely not the right way to go about this, and rather, systemd / running the commands once at startup might be better.
I saw the issue #77 (systemd example) but face the same challenge of how to pass the flag, and ultimately start 2 services. One for CTRL and one for BATT.
EDIT: I have now added my solution / what is working for me using systemd over on issue #77
In case it is of any help or inspiration to others, I am sharing what I have done to assist with checking that the CRONS are running as expected and to be able to unpick errors if anything stops working.
I also share this in case it helps drive any improvements to the logging system or the readme/setup instructions.
I could not tell if this was already being logged anywhere, please let me know if what I have done is redundant.
Here is what I have done.
in example.py I included:
from datetime import datetime
At the topI then added additional logging after around line 16:
I created a 'logs' folder in the same location as the project files.
Now as the script gets called from my cron, it will create a log for today, and it will do it per instance. So for example, I have one cron loading the battery config and another loading the controller config. I will end up with a log for each of those.
Each time a new day arrives, a new log file will be created for each of them.
I am running a Pi 5, and the python scripts are running in a venv / virtual environment. For anyone that is interested, this is how my working cron lines ended up
I will likely set up another cron to clean out old log files that are 30 days old at some point.
Once I know that everything is running well for a while, I will likely change down the logging to just capture errors, and potentially send a notification somewhere.
I am a beginner at best so this is me muddling my way through. I find that having more logs and information helps me better understand how things are working and resolve problems, but right now I am also learning the logging system and approaches themselves. So please don't judge me too harshly :)
p.s wasn't sure if this should be in 'issues' or 'discussions' - apologies if this is incorrectly submitted, and do let me know the correct approach moving forward.