uroflavin / hcloud-calendar-automation

hetzner cloud automation with the help of a public accessible (web/i)calendar
GNU General Public License v3.0
1 stars 0 forks source link

sleep time should within timeslice_grid_interval #1

Open uroflavin opened 3 years ago

uroflavin commented 3 years ago

Sleep time is currently static: every 60 seconds we check if server should/not run and is/not running.

This process is already optimized to reduce network load. But if there is a timeslice-gridinterval of 15 minutes, nothing would change within this time.

Using timegrid-intervall might be a good choice, but we have to deal with start and end-time. Otherwise we may miss a time slice and the server will run longer than necessary

uroflavin commented 3 years ago

idea 1: use grid_timeslice and grid_datetime to calc sleep time. if we have no True in grid_timeslice for the next xx minutes, we can sleep, until xx+1 minutes. the second condition is to also consider the cache time. this means: max sleep time could only be "cache-time".

calc sleeptime: (next grid_datetime [which is true]) minus now.timestamp