Problem shutting down / restarting HA

Hi all,

Enjoying HA a great deal but recently I saw a problem closing it down - doesn’t seem to close properly, am starting to think it’s one of my configuration settings that might be preventing HA closing / restarting elegantly…

^CINFO:homeassistant.core:Stopping INFO:homeassistant.core:Bus:Handling <Event homeassistant_stop[L]> INFO:homeassistant.components.wemo:Shutting down subscriptions. INFO:homeassistant.components.recorder:Closing database INFO:netdisco.service:Scanning

Above logging output shows m pressing ctrlC and then waiting, it quickly goes to “closing database” but then hangs there for a min or so, then i see, INFO:netdisco.service:Scanning… So it never actually shutsdown as I’d expect it to.

If I ctrl-c again it quits (inelegantly).

INFO:netdisco.service:Scanning ^CTraceback (most recent call last): File "/usr/local/bin/hass", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python3.4/dist-packages/homeassistant/__main__.py", line 386, in main exit_code = setup_and_run_hass(config_dir, args) File "/usr/local/lib/python3.4/dist-packages/homeassistant/__main__.py", line 308, in setup_and_run_hass exit_code = int(hass.block_till_stopped()) File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 109, in block_till_stopped self.stop() File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 117, in stop self.pool.stop() File "/usr/local/lib/python3.4/dist-packages/homeassistant/util/__init__.py", line 381, in stop self.block_till_done() File "/usr/local/lib/python3.4/dist-packages/homeassistant/util/__init__.py", line 375, in block_till_done self._work_queue.join() File "/usr/lib/python3.4/queue.py", line 86, in join self.all_tasks_done.wait() File "/usr/lib/python3.4/threading.py", line 290, in wait waiter.acquire() KeyboardInterrupt pi@custard-pi:~ $

Anyone got an idea what might be happening here or seen similar.

thanks

What platform are you using for HA? Windows? Docker? Pi?

It’s a pi2, latest image, jessie lite.

I ask because I’ve been noticing the same thing on occasion with my Pi3 that I set up with the AIO installer. Just curious; do you have a lot of sensor templates in use?

Not too many, about 3, speedtest, yr and a temp sensor doing updates via mqtt.

Well that rules out that idea. I just started using a number of sensor templates as a result of implementing this:

and was wondering if all the template sensors are causing a worker pool traffic jam. Have you grepped your log for worker pool tasks? Seeing any lineups in the queue?

I am seeing this too on a Pi3 + AIO -

I had tracked the issue down to the MQTT Event Feed - that prevented shutdown 100% of the time, but now I am no longer using it, I still get a failure to shutdown cleanly perhaps 50% or so of the time.

I do have a large number of sensors and templates.

Hmm, I’m barely using MQTT at the moment; I’m using CloudMQTT with Owntracks. But I do have a large number of sensors and templates like yourself.

Not sure what this is but there’s something stopping HA from shuting down elegantly I believe.

Still no resolution - I tried a fresh install but no luck. Seems like the database just doesn’t want to close when I tell it to. Any other tips ?

Apparently a Hot fix was pushed out for issues with the front end - did you upgrade?

Upgraded, problem still there, I hit CTRL-C and it says…

^CINFO:homeassistant.core:Stopping
INFO:homeassistant.core:Bus:Handling <Event homeassistant_stop[L]>
INFO:homeassistant.components.wemo:Shutting down subscriptions.
INFO:homeassistant.components.recorder:Closing database
INFO:netdisco.service:Scanning

But it doesn’t stop, unless I Ctrl-C again when it quits inelegantly.

problem still persists in latest version - is it just the RPI2 is sloooooooowww.
Hangs at closing db duroing shutdown.

I have seen an improvement over the last few days - not 100% but it seems to shutdown more reliably on my Pi3.

I ddi some testing to try and isolate the problem and I think I have !

So I tried a fresh install on a Pi with default config and without any items auto dsicovered - shutdown is fine.
I took my own install and deleted the config and restarted - only thing discovered was hue lights - shutdown stalls.
I took my own install and editted the default config to disable device discovery and restarted - nothing discovered predictably, shutdown is instant!

So it’s the hue lights / hub somehow stopping the shutdown, no message in the log though - that’s my reading anyway.

Anyone further ideas people ?

It may not be the Hue specifically - the system will be a heck of a lot less busy with no device state to worry about. I have Hue and ZWave, so I’ll run a test to see if disabling the hue but leaving the ZWave running helps, although as I previously observed things are alot better for me on the latest release.

It seems to be the discovery component in my case. I disable that and it shuts down immediately!

Just wanted to observe that without any particular changes my system has been a lot more stable and a LOT better about shutting down since the new web piece went in a couple of releases ago. It is now the exception rather than the rule that it fails so shutdown.

I agree; I have had one or two times when it wouldn’t restart lately but not as bad as before.

Hi to everyone,

Yesterday after rebooting Raspi (i think so) i have more or less the same problem…

here you can see the topic that i opened: https://community.home-assistant.io/t/problem-to-start-ha-from-today-yesterday-worked-well/5102/2

Someone knows the reason about this?

thanks