ScottSturdivant / rpi_metar

METAR LED Display for a Raspberry Pi
MIT License
26 stars 16 forks source link

Suggest Fix - Autostart not working on Raspbian Buster #17

Closed fast240z closed 4 years ago

fast240z commented 4 years ago

Autostart is not working in Raspbian Buster using the current example rpi_metar.service in the github and python instructions.

The script is starting before the network has completed init and is crashing. A simple fix is to add the following under Unit:

[Unit] Description=METAR Display Wants = network-online.target After = network.target network-online.target

[Service] ExecStart=/opt/rpi_metar/bin/rpi_metar User=root Group=root Restart=always

[Install] WantedBy=multi-user.target

ScottSturdivant commented 4 years ago

Thanks for the report!

Are you able to provide logs of the crashing service? Rather than delaying the service start up, it might be better to make the service more robust in the face of network outages. Curious if what you're seeing would potentially be an issue in the event that the network drops after it had been running.

fast240z commented 4 years ago

Mar 04 04:31:07 metarmap systemd[1]: Started METAR Display. Mar 04 04:31:07 metarmap rpi_metar[424]: Traceback (most recent call last): Mar 04 04:31:07 metarmap rpi_metar[424]: File "/opt/rpi_metar/bin/rpi_metar", line 6, in Mar 04 04:31:07 metarmap rpi_metar[424]: from rpi_metar.core import main Mar 04 04:31:07 metarmap rpi_metar[424]: File "/opt/rpi_metar/lib/python3.7/site-packages/rpi_metar/init.py", line 17, in Mar 04 04:31:07 metarmap rpi_metar[424]: papertrail = logging.handlers.SysLogHandler(address=('logs2.papertrailapp.com', 43558)) Mar 04 04:31:07 metarmap rpi_metar[424]: File "/usr/lib/python3.7/logging/handlers.py", line 828, in init Mar 04 04:31:07 metarmap rpi_metar[424]: ress = socket.getaddrinfo(host, port, 0, socktype) Mar 04 04:31:07 metarmap rpi_metar[424]: File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo Mar 04 04:31:07 metarmap rpi_metar[424]: for res in _socket.getaddrinfo(host, port, family, type, proto, flags): Mar 04 04:31:07 metarmap rpi_metar[424]: socket.gaierror: [Errno -3] Temporary failure in name resolution Mar 04 04:31:07 metarmap rpi_metar[424]: Error in atexit._run_exitfuncs: Mar 04 04:31:07 metarmap rpi_metar[424]: Traceback (most recent call last): Mar 04 04:31:07 metarmap rpi_metar[424]: File "/usr/lib/python3.7/logging/init.py", line 2039, in shutdown Mar 04 04:31:07 metarmap rpi_metar[424]: h.close() Mar 04 04:31:07 metarmap rpi_metar[424]: File "/usr/lib/python3.7/logging/handlers.py", line 891, in close Mar 04 04:31:07 metarmap rpi_metar[424]: self.socket.close() Mar 04 04:31:07 metarmap rpi_metar[424]: AttributeError: 'SysLogHandler' object has no attribute 'socket' Mar 04 04:31:07 metarmap systemd[1]: rpi_metar.service: Main process exited, code=exited, status=1/FAILURE Mar 04 04:31:07 metarmap systemd[1]: rpi_metar.service: Failed with result 'exit-code'. Mar 04 04:31:08 metarmap systemd[1]: rpi_metar.service: Service RestartSec=100ms expired, scheduling restart. Mar 04 04:31:08 metarmap systemd[1]: rpi_metar.service: Scheduled restart job, restart counter is at 5. Mar 04 04:31:08 metarmap systemd[1]: Stopped METAR Display. Mar 04 04:31:08 metarmap systemd[1]: rpi_metar.service: Start request repeated too quickly. Mar 04 04:31:08 metarmap systemd[1]: rpi_metar.service: Failed with result 'exit-code'. Mar 04 04:31:08 metarmap systemd[1]: Failed to start METAR Display.