shutdown/restart Homeassistant recorder/sqlite #294

Closed
opened 2022-09-15 11:03:28 +02:00 by jump · 4 comments

Is there a way to shutdown or restart the Homeassistance instance without start-stop-daemon? Restarting the instance in the frontend (Developer Tools/Restart) leads to a crashed openrc daemon.

Linked to this issue is the error logged by recorder

The system could not validate that the sqlite3 database was shutdown cleanly

To prevent this error I had to modify the init script to set a recorder end time in the sqlite database (vacuum is only for compression).

stop() {
        ebegin "Stopping ${RC_SVCNAME}"
        start-stop-daemon --stop --signal USR1 --pidfile /var/run/${RC_SVCNAME}.pid
	sleep 3
	/usr/bin/sqlite3 /etc/homeassistant/home-assistant_v2.db "UPDATE recorder_runs SET end=(datetime('now','localtime')) ORDER BY start DESC LIMIT 1"
	/usr/bin/sqlite3 /etc/homeassistant/home-assistant_v2.db "VACUUM"
        eend

Is there a way to shutdown or restart the Homeassistance instance without start-stop-daemon? Restarting the instance in the frontend (Developer Tools/Restart) leads to a crashed openrc daemon. Linked to this issue is the error logged by recorder ``` The system could not validate that the sqlite3 database was shutdown cleanly ``` To prevent this error I had to modify the init script to set a recorder end time in the sqlite database (vacuum is only for compression). ``` stop() { ebegin "Stopping ${RC_SVCNAME}" start-stop-daemon --stop --signal USR1 --pidfile /var/run/${RC_SVCNAME}.pid sleep 3 /usr/bin/sqlite3 /etc/homeassistant/home-assistant_v2.db "UPDATE recorder_runs SET end=(datetime('now','localtime')) ORDER BY start DESC LIMIT 1" /usr/bin/sqlite3 /etc/homeassistant/home-assistant_v2.db "VACUUM" eend ```
onkelbeh self-assigned this 2022-09-15 18:37:26 +02:00

Looks like #260, never had a problem like that because my recorder writes to a mariadb. We could take it into the regular init controlled by a UseFlag.

Looks like #260, never had a problem like that because my recorder writes to a mariadb. We could take it into the regular init controlled by a UseFlag.
Also mentioned in https://github.com/home-assistant/core/issues/73679

Again I would recommend to use MariaDB.

Again I would recommend to use MariaDB.

My sqlite database grows more or less 3MB per week after sqlite/vakuum. Because my Mysql databases are on an encrypted volume and not available after a power loss I`ll stay with sqlite for the moment.

My sqlite database grows more or less 3MB per week after sqlite/vakuum. Because my Mysql databases are on an encrypted volume and not available after a power loss I`ll stay with sqlite for the moment.
jump closed this issue 2022-10-06 14:15:31 +02:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: onkelbeh/HomeAssistantRepository#294
There is no content yet.