tfabris / CrowCam

A set of Bash scripts to control and maintain a YouTube live cam from a Synology NAS.
GNU General Public License v3.0
4 stars 3 forks source link

Retrieving sunrise/sunset time from google sometimes gets error message. #18

Closed tfabris closed 5 years ago

tfabris commented 5 years ago

Every night, the Synology NAS log gets one instance of the Info message saying "Problem obtaining sunrise/sunset from Google...". It is expected to happen because the router/firewall on our LAN does a self-healing nightly reboot at 3:30am every night.

I would like to figure out how to suppress this error message during the nightly reboot, but otherwise display the error message at other times.

There is a catch-22 in the code which makes this tricky. Ideally, I would want to skip it when I don't need it. For example, skipping the google search or suppressing the error message when the live stream isn't supposed to be up and running, or skipping the search when the network is down. The problem is, the sunrise/sunset time needs to be "known" in order to accurately make that decision; you can't make a decision based on the sunrise/sunset time before the sunrise/sunset query.

Ideas:

tfabris commented 5 years ago

Advantages/Disadvantages:

Suppress the message altogether:

Hard code times of day to skip the google search:

Pre-google-search network test:

Only re-query when we're nearing sunrise/sunset:

Start the script using the previously-saved time and then only re-query at the end.

Consider the following instead:

Perhaps should just leave this be?

tfabris commented 5 years ago

On 2019-04-18, looking at the logs I noticed that there were large swaths of time where the retrieval of the sunrise/sunset time got an error, even though the network was up.

When deciding how to handle this, it is thus important to keep in mind that a failure of the google search and a failure of the network will not always go hand in hand.

Other thoughts:

Consider this option:

tfabris commented 5 years ago

I've implmented that last idea about only refreshing the google times if the files are old enough.

Note: Need to test this on a Mac Laptop before considering this issue closed. Sometimes I've had issues with the command line parameters to Bash commands not working as expected on a Mac, and this is the first time I'm using the bash "find" command in this script.

tfabris commented 5 years ago

I have placed this code into production on the NAS, but there is still a problem with the code running on the Mac laptop.

Line 870 currently has a problem if the location of the files is in a folder containing a space in the path name. The place where it executes "find (filename)" has a problem if (filename) contains a space. It's embedded in an IF statement and the statement responds with "unary operator expected".

However ADDING QUOTES AROUND THE FILE NAME DOES NOT FIX THE PROBLEM. Grr.

Need to research this issue in detail and get to the bottom of it. In the meantime, the production code should theoretically be working.

tfabris commented 5 years ago

The most recent checkin will address the issue in all environments. The prior code (still running on the production server at this time) works fine on the production server because there are no spaces in the path name, so it's not a critical hurry to get the new code deployed to production yet. Though leave this bug open until the code really is deployed into production.

tfabris commented 5 years ago

Code is deployed to production. Let's see how it does.