HA restarts very slow

looking at the syslog

This is what I get when I do a sudo systemctl restart home-assistant@hass

Dec 20 15:20:30 hass systemd[1]: Stopping Home Assistant...
Dec 20 15:20:30 hass hass[10219]: #033[32m16-12-20 15:20:30 INFO (MainThread) [homeassistant.core] Bus:Handling <Event homeassistant_stop[L]>#033[0m
Dec 20 15:20:30 hass hass[10219]: #033[32m16-12-20 15:20:30 INFO (Thread-8) [pubnubsubhandler] PubNub unsubscribing#033[0m
Dec 20 15:20:30 hass hass[10219]: #033[32m16-12-20 15:20:30 INFO (Thread-4) [homeassistant.components.zwave] Stopping ZWave network.#033[0m
Dec 20 15:20:30 hass hass[10219]: #033[32m16-12-20 15:20:30 INFO (Thread-4) [openzwave] Stop Openzwave network.#033[0m
Dec 20 15:20:30 hass hass[10219]: #033[32m16-12-20 15:20:30 INFO (Thread-4) [openzwave] ZWave configuration written to user directory.#033[0m
Dec 20 15:20:30 hass hass[10219]: #033[32m16-12-20 15:20:30 INFO (EndpointThread-Leave-0) [pubnubsubhandler] PubNub disconnected (lost internet?)#033[0m
Dec 20 15:21:08 hass hass[10219]: #033[32m16-12-20 15:21:08 INFO (Thread-13) [netdisco.service] Scanning#033[0m
Dec 20 15:21:40 hass named[602]: error (network unreachable) resolving 'ntp-g7g.amazon.com/A/IN': 2001:502:f3ff::1#53
Dec 20 15:21:40 hass rsyslogd-2007: action 'action 17' suspended, next retry is Tue Dec 20 15:23:10 2016 [try http://www.rsyslog.com/e/2007 ]
Dec 20 15:22:00 hass systemd[1]: [email protected] stop-sigterm timed out. Killing.
Dec 20 15:22:00 hass systemd[1]: [email protected]: main process exited, code=killed, status=9/KILL
Dec 20 15:22:00 hass systemd[1]: Unit [email protected] entered failed state.
Dec 20 15:22:00 hass systemd[1]: Starting Home Assistant...
Dec 20 15:22:00 hass systemd[1]: Started Home Assistant.

Notice at 15:22:00 the shutdown seems to timeout and just get killed. This doesn’t happen when doing it through the webpage.

This is what I get when I use the restart service through the web page

Dec 20 15:28:17 hass hass[10547]: #033[32m16-12-20 15:28:17 INFO (Thread-9) [pubnubsubhandler] PubNub unsubscribing#033[0m
Dec 20 15:28:17 hass hass[10547]: #033[32m16-12-20 15:28:17 INFO (Thread-6) [homeassistant.components.zwave] Stopping ZWave network.#033[0m
Dec 20 15:28:17 hass hass[10547]: #033[32m16-12-20 15:28:17 INFO (Thread-6) [openzwave] Stop Openzwave network.#033[0m
Dec 20 15:28:17 hass hass[10547]: #033[32m16-12-20 15:28:17 INFO (Thread-6) [openzwave] ZWave configuration written to user directory.#033[0m
Dec 20 15:28:17 hass hass[10547]: #033[32m16-12-20 15:28:17 INFO (EndpointThread-Leave-0) [pubnubsubhandler] PubNub disconnected (lost internet?)#033[0m
Dec 20 15:30:32 hass hass[10547]: #033[32m16-12-20 15:30:32 INFO (Thread-13) [netdisco.service] Scanning#033[0m
Dec 20 15:30:32 hass rsyslogd-2007: action 'action 17' suspended, next retry is Tue Dec 20 15:32:02 2016 [try http://www.rsyslog.com/e/2007 ]
Dec 20 15:32:17 hass named[602]: error (network unreachable) resolving './NS/IN': 2001:503:ba3e::2:30#53
Dec 20 15:32:17 hass named[602]: error (network unreachable) resolving 'google.com/DS/IN': 2001:503:ba3e::2:30#53
Dec 20 15:32:17 hass rsyslogd-2007: action 'action 17' suspended, next retry is Tue Dec 20 15:33:47 2016 [try http://www.rsyslog.com/e/2007 ]
Dec 20 15:32:40 hass named[602]: error (network unreachable) resolving './NS/IN': 2001:7fe::53#53
Dec 20 15:32:40 hass named[602]: error (network unreachable) resolving './NS/IN': 2001:503:c27::2:30#53
Dec 20 15:32:40 hass named[602]: error (network unreachable) resolving 'ndmdhs.com/DS/IN': 2001:7fe::53#53
Dec 20 15:32:40 hass named[602]: error (network unreachable) resolving 'ndmdhs.com/DS/IN': 2001:503:c27::2:30#53

Seems to be a bug, that you should report here: https://github.com/home-assistant/home-assistant/issues/new

I also have to wait for a time-out by shutdown…
Using command sudo systemctl restart home-assistant@hass

Dec 21 16:34:04 raspberrypi systemd[1]: Stopping Home Assistant...
Dec 21 16:34:04 raspberrypi hass[31143]: 16-12-21 16:34:04 INFO (MainThread)[homeassistant.core] Bus:Handling <Event homeassistant_stop[L]>
Dec 21 16:35:34 raspberrypi systemd[1]: [email protected] stop-sigterm timed out. Killing.

It is a suggestion for a fix here https://github.com/home-assistant/home-assistant/issues/5027

I have one question due to a slow restart of HA. It is not possible to install HA on raspberry pi on external hard drive? In this way, it will bee bore faster.

You can install HA where you want.

How can I choose where to install HA? I want to make a try to see if it’s much quicker on the external drive.

OK, I see…I should make a fresh install. Now it is not possible to just move all my HA stuff on the external drive without another fresh installation?

What should i use as the localhost?

This bug is fixed in the latest dev version.

Hi, guys!
So, i just found some workaround.
If you a sure in your code in *.yaml, and just need to restart service (sudo systemctl restart home-assistant.service or sudo systemctl stop/start home-assistant.service) and you want to do it fast, you can change the permissions to the log file (chmod 744).
HA can’t write to log file and restart take few seconds.
!!ATTENTION!!
In this case your log file will not be updated. In case of errors, HA service will not started, and you need to change permission as it was before, to identify error.

I also noticed when the db gets over 500mb HA takes a LONG time to restart. Deleting the db file allows it to recreate and runs way faster. I’m curious about the chmod fix though. I’ll give that a try too. Thanks.

I too have this problem after switching to MySql. If restarting from the HA web page, it’s very slow.

Mine also take 20+ mins to boot up, but im just guessing that its because its running on a gen1 Respberry pi

i was running on a RPi 2. Switching to a RPI 3 decreased startup time from 6-7 min to 1 min or so. this is with the sqlite DB and NOT removing database file.

The restart issue for me seems to be with HA shutting down. A few releases ago it seemed fixed, but it’s now back. It could have been some configuration changes on my side as well.

Alan

what I find with the shutdown is that the zwave config shuts down fairly quickly, but sometimes the event loop in HA doesn’t seem to get the message and keeps processing events from other sources. When that happens, I have to just kill it and restart it manually. It seems to happen this way to me about 50% of the time.