0

Restarting on loss of Internet connection
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Restarting on loss of Internet connection

by wsquared58 on Sat Sep 07, 2019 7:10 am

I there a way to restart/reset a dropped internet connection when sending data to IO?
Our local Spectrum provider is notorious for twitchy and inconsistent connectivity.

I am running some weather sensors via python and invariably at some point there will be a hiccup in connectivity and the program stops. Certainly have no expectation that the issue with the provider is going to get resolved so need thoughts on how to fire program up once connectivity returns. Is this something that systemd would work for?

What I'm alluding to with systemd is these lines from a site that I dug up.

Code: Select all | TOGGLE FULL SIZE
User=pi
ExecStart=/usr/bin/python3 /home/pi/MyProgram.py

Restart=always
RestartSec=0

[Install]
WantedBy=multi-user.target


‘Restart’ set to ‘always’ tells systemd to monitor the process it has started, and if it stops, systemd will restart it.
‘RestartSec’ tells systemd to wait 0 seconds before restarting the program if it exits.


Since these drops of connectivity are vriable in nature but generall but maybe 1 - 5 minutes, rather that have RestartSec=0, maybe RestartSec=300 or something along those lines since the weather sensors are sending data every 5 minutes there shouldn't be any big loss of data regardless?

wsquared58
 
Posts: 124
Joined: Sun Jun 09, 2019 9:13 pm

Please be positive and constructive with your questions and comments.