Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 874

HATs and other add-ons • Re: Run script requiring network before shutdown or reboot

$
0
0
Hey :)

I'm failing to make this work. I don't have a wireguard service running, so I assume it' enough to have something like this:

Code:

[Unit]Description=Log Shutdown to serverAfter=network-online.target[Service]Type=oneshotExecStart=/bin/trueExecStop=/usr/bin/python /home/user/log_shutdown.pyRemainAfterExit=yes[Install]WantedBy=multi-user.target
Still it produces python urllib connection errors as it runs after logs like this:

Code:

Apr 19 20:26:56 raspberrypi systemd[1]: Stopping WPA supplicant...Apr 19 20:26:56 raspberrypi systemd[1]: Stopping Raise network interfaces...Apr 19 20:26:55 raspberrypi systemd[1]: Stopping Network Manager...Apr 19 20:26:55 raspberrypi NetworkManager[271]: <info>  [1713551215.9894] caught SIGTERM, shutting down normally.Apr 19 20:26:55 raspberrypi systemd[1]: Stopped Network Manager Wait Online.Apr 19 20:26:55 raspberrypi systemd[1]: NetworkManager-wait-online.service: Succeeded.Apr 19 20:26:55 raspberrypi systemd[1]: Stopped target Network.Apr 19 20:26:55 raspberrypi systemd[1]: Stopped target Network is Online.Apr 19 20:26:55 raspberrypi systemd[1]: rcshutdown.service: Consumed 5.948s CPU time.Apr 19 20:26:55 raspberrypi systemd[1]: Stopped Log Shutdown to server.Apr 19 20:26:55 raspberrypi systemd[1]: rcshutdown.service: Succeeded....Apr 19 20:26:55 raspberrypi python[2287]: urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0xb5e0e880>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolutionApr 19 20:26:55 raspberrypi python[2287]:     raise NewConnectionError(Apr 19 20:26:55 raspberrypi python[2287]:   File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 181, in _new_connApr 19 20:26:55 raspberrypi python[2287]:     conn = self._new_conn()Apr 19 20:26:55 raspberrypi python[2287]:   File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 353, in connectApr 19 20:26:55 raspberrypi python[2287]:     conn.connect()Apr 19 20:26:55 raspberrypi python[2287]:   File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 1012, in _validate_connApr 19 20:26:55 raspberrypi python[2287]:     self._validate_conn(conn)Apr 19 20:26:55 raspberrypi python[2287]:   File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 382, in _make_requestApr 19 20:26:55 raspberrypi python[2287]:     httplib_response = self._make_request(Apr 19 20:26:55 raspberrypi python[2287]:   File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopenApr 19 20:26:55 raspberrypi python[2287]: Traceback (most recent call last):Apr 19 20:26:55 raspberrypi python[2287]: During handling of the above exception, another exception occurred:Apr 19 20:26:55 raspberrypi python[2287]: socket.gaierror: [Errno -3] Temporary failure in name resolutionApr 19 20:26:55 raspberrypi python[2287]:     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):Apr 19 20:26:55 raspberrypi python[2287]:   File "/usr/lib/python3.9/socket.py", line 953, in getaddrinfoApr 19 20:26:55 raspberrypi python[2287]:     for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):Apr 19 20:26:55 raspberrypi python[2287]:   File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 73, in create_connectionApr 19 20:26:55 raspberrypi python[2287]:     conn = connection.create_connection(Apr 19 20:26:55 raspberrypi python[2287]:   File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_connApr 19 20:26:55 raspberrypi python[2287]: Traceback (most recent call last):Apr 19 20:26:55 raspberrypi python[2287]: --- Logging error ------- my script startsApr 19 20:26:51 raspberrypi NetworkManager[271]: <info>  [1713551211.4750] device (p2p-dev-wlan0): supplicant management interface state: interface_disabled -> disconnectedApr 19 20:26:51 raspberrypi NetworkManager[271]: <info>  [1713551211.4747] device (wlan0): supplicant interface state: interface_disabled -> disconnectedApr 19 20:26:51 raspberrypi NetworkManager[271]: <info>  [1713551211.4733] device (p2p-dev-wlan0): supplicant management interface state: disconnected -> interface_disabledApr 19 20:26:51 raspberrypi NetworkManager[271]: <info>  [1713551211.4690] device (wlan0): supplicant interface state: disconnected -> interface_disabledApr 19 20:26:51 raspberrypi dbus-daemon[245]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.nm-dispatcher.service': Refusing activation, D-Bus is shutting down.Apr 19 20:26:51 raspberrypi dbus-daemon[245]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.5' (uid=0 pid=271 comm>Apr 19 20:26:51 raspberrypi NetworkManager[271]: <warn>  [1713551211.2828] dns-mgr: could not commit DNS changes: /sbin/resolvconf returned error codeApr 19 20:26:51 raspberrypi NetworkManager[2409]: /sbin/resolvconf: 31: kill: No such processApr 19 20:26:50 raspberrypi NetworkManager[271]: <info>  [1713551210.4041] dns-mgr: Removing DNS information from /sbin/resolvconfApr 19 20:26:50 raspberrypi NetworkManager[271]: <warn>  [1713551210.3757] dns-mgr: could not commit DNS changes: resolvconf failed with status 256Apr 19 20:26:50 raspberrypi NetworkManager[271]: <warn>  [1713551210.3648] dns-mgr: resolvconf failed with status 256Apr 19 20:26:50 raspberrypi NetworkManager[2362]: /sbin/resolvconf: 31: kill: No such processApr 19 20:26:49 raspberrypi systemd[1]: Stopped target NFS client services.Apr 19 20:26:49 raspberrypi systemd[1]: Stopped target Remote File Systems (Pre).Apr 19 20:26:49 raspberrypi systemd[1]: Stopped target Remote File Systems.Apr 19 20:26:49 raspberrypi systemd[1]: Stopped Permit User Sessions.
Any ideas what to do?

Statistics: Posted by mmoollllee — Fri Apr 19, 2024 6:33 pm



Viewing all articles
Browse latest Browse all 874

Trending Articles