[Solved] Reboot or Shutdown Raspberry safely closes Domoticz?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

[Solved] Reboot or Shutdown Raspberry safely closes Domoticz?

Post by McJohn »

We are confused by different posts about how to safely shutdown the Domotics database.
This post says:

https://www.domoticz.com/forum/viewtopic.php?t=21895
Siewert308SW wrote: Saturday 27 January 2018 13:57 First of all a reboot like you do/want aint good.
"sudo reboot" doesn't take care of Domoticz which needs a proper shutdown.
Meaning, you will hit a time that your database gets corrupt.
It will happen for sure that a read/write to the database is interrupted.
There are many ways like for example a simple bash called from cron.
And then stop domoticz service and afterwards then conduct a reboot.
But in another post stays;

https://www.domoticz.com/forum/viewtopi ... 11&t=13736
Egregius wrote: Monday 17 October 2016 16:11

Code: Select all

http://192.168.2.10:8084/json.htm?type=command&param=system_shutdown 
should do it as that is the url that the www gui calls.
So, what's the difference between a sudo reboot (or shutdown) or by example a reboot with an ssh session (or reboot in the GUI of the Raspberry) for Domotics?
Is it always so that a reboot or shutdown into the Raspberry not safely closes the Domotics database?

Thanks in advance for the explanation.
Last edited by McJohn on Sunday 16 June 2019 11:57, edited 1 time in total.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Reboot or Shutdown Raspberry safely closes Domoticz?

Post by EddyG »

Normally Domoticz is started as a service under control of systemd.
When you issue a command like "sudo reboot" then system will close all open files and reboot.
It does a kind of "sudo systemctl stop <service>" for all services, which issues a TERM signal to the running services.
So no harm will be done, I did it thousands of times.
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: Reboot or Shutdown Raspberry safely closes Domoticz?

Post by McJohn »

Thank you very much for the quick response and the tranquillized words!

Then this post don't give the right information:
Siewert308SW wrote: ↑Saturday 27 January 2018 14:57
First of all a reboot like you do/want aint good.
"sudo reboot" doesn't take care of Domoticz which needs a proper shutdown.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Reboot or Shutdown Raspberry safely closes Domoticz?

Post by EddyG »

No, it does not. Like I wrote, I did it thousands of times and never run into trouble.
Read https://en.wikipedia.org/wiki/Systemd and all the links in it and you will be an expert on this subject. ;)
Or https://www.linux.com/learn/understandi ... ng-systemd
A command like "systemd-analyze blame" analyse the startup of different services.
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: Reboot or Shutdown Raspberry safely closes Domoticz?

Post by McJohn »

Thank you very much for all the information! :)

OK, what I understood is that systemd "kills" all the running services at a reboot or shutdown?

Isn't it be a nicer way to place a file into the directory /lib/systemd/system-shutdown with a script with the command:
'sudo service domoticz.sh stop" ?
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Reboot or Shutdown Raspberry safely closes Domoticz?

Post by EddyG »

No, you cannot just put a script in /lib/systemd/system-shutdown.
Systemd is the proper way to control boot, reboot and shutdown if it is installed.
Services are getting a proper SIGTERM signal instead of the SIGKILL signal and are allowed to close files in the right way.
It's close to what the old "sudo service domoticz.sh stop" would do.
B.t.w. the old "sudo service" is transfered to "sudo systemctl", which is used to control systemd services.
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: Reboot or Shutdown Raspberry safely closes Domoticz?

Post by McJohn »

Thanks for the clear explanation. Case closed and everything is working well.
(For a Raspberry without a screen, we put a bash script with espeak command, into the /lib/systemd/system-shutdown directory
it says "Shutdown the system" trough the speaker, so, we know the Raspberry is on halt :D )
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest