This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the expected experience using the safe power-off feature?
#1
I have set up two separate installs of OpenPlotter with MacArthur HAT on Raspberry Pi5 - both have the power board that allows for a graceful power-down through toggling GPIO, and both are using the latest beta image.

The experience I am seeing when I use the graceful power-off feature are as follows:
  1. I flip the switch that toggles the power-off GPIO.
  2. The standard RPi dialog pops up asking "Restart, Shutdown, etc".
  3. 1-2 seconds later, without clicking any of the above options, the system appears to power-off correctly.

When I flip the power toggle back on, and the system starts up, I get a message about "The last opencpn run seems to have failed - do you want to start it in Safe Mode?"

I just wanted to make sure that the above was the expected current experience.  Thanks
Reply
#2
Yes, that is the expected behavior. You can ignore that OpenCPN message because it means that OpenCPN was closed by another program, in this case it is the OS. I think that message is too alarmist but fortunately if you ignore it everything starts as it should.
Reply
#3
(2024-05-13, 11:37 AM)Sailoog Wrote: Yes, that is the expected behavior. You can ignore that OpenCPN message because it means that OpenCPN was closed by another program, in this case it is the OS. I think that message is too alarmist but fortunately if you ignore it everything starts as it should.

Awesome, thanks very much for the confirmation.  I just wanted to make sure that a graceful shutdown was actually happening so I am not risking some kind of data corruption.
Reply
#4
@Saillog
The Shutdown-Process should check for an running OpenCPN App,
and if it is running, tell OpenCPN to quit gracefully. Or, if that is difficult, close the Main OpenCPN Window.
Then wait some seconds and after this settle the rude "shutdown -h now" to the kernel.

This would be better behavior, right?
If i manualy close my OpenCPN Window, it also remembers its actual Preferences & never quakes after an Restart.

ym2c - holger
Reply
#5
I am afraid that is not how it works. There is no way to close OpenCPN outside of OpenCPN without receiving this warning. When you close the "Main OpenCPN Window", you close OpenCPN from within OpenCPN, so there is no warning but any other attempt of closing OpenCPN will generate the warning.

The "shutdown" command and the like do exactly what you are proposing, they cleanly close all processes before exiting.

In short, this OpenCPN warning does not mean that OpenCPN has been closed incorrectly, it means; "Someone else closed the program, so I am giving you the option to disable plugins in case something goes wrong."
Reply
#6
Hello Saillog

the shutdown uses an "killall -9 <PID>" command (SIGKILL". this is very agressive and does not give other programs enought time to quit.

so it is better to use an softer kill for opencpn like only "kill <PID>" (defaults to SIGTERM) earlier only for opencpn.

https://linuxcommandsshellscripting.quor...x-terminal

ym2c
Reply
#7
When a Unix-like system is shut down normally, e.g. using halt, shutdown, poweroff etc. or the GUI equivalents, it will try to exit all processes gracefully first by emitting a SIGTERM signal to them. After some time it will send SIGKILL to the programs which are still running.

We use halt in openplotter.

Opencpn may always get a SIGKILL, so the problem is that opencpn does not react to SIGTERM and it would be useless for us to send it. Something to talk about with the opencpn developers without a doubt.
Reply
#8
Thinking about this... currently when using the shutdown options in openplotter-settings, we catch the shutdown event to avoid the Raspberry OS dialog and achieve an automatic shutdown without user intervention (MacArthur HAT shutdown feature): https://github.com/openplotter/openplott...hutdown.py

It would not hurt to add "pkill -15 opencpn" before the halt command to see if it makes a difference. Let me do some tests...
Reply
#9
Ops you are right, Raspberry OS is not sending SIGTERM at shutdown Huh

I was told that that initial message from opencpn would always appear no matter how opencpn was closed but I just found out that it is not true. The warning does not appear with -15 and clearly Raspberry OS does not send it.

Holgerw now I see that your proposal makes perfect sense and is easy to implement. Any other programs to be added to the kill list?
Reply
#10
Not now, most Do not have their config file open for writing like opencpn.
Thanks a lot for getting into.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)