How to properly stop Kodi on a Raspberry Pi 3 Model B?

This forum is for topics dealing with problems with software specifically in the ARMv7h repo.

How to properly stop Kodi on a Raspberry Pi 3 Model B?

Postby blablubb1234 » Fri Jan 07, 2022 3:29 pm

Hi,

I just installed Kodi 19.3-3 on a Raspberry Pi 3 Model B Rev 1.2 running an up-to-date ArchLinuxARM.

The (ArchLinux) wiki article regarding Kodi is of course not ARM-centric, but it states:

Be aware that these services run Kodi in systemd's user.slice, not system.slice. In order to have Kodi exit gracefully, initiate system reboot/shutdown with the respective Kodi actions instead of systemctl. Failure to do so will result in an ungraceful exit of Kodi and the loss of GUI settings, Kodi uptime etc.


The kodi.service unit provided in the ARM package of Kodi looks like this:

Code: Select all
cat /usr/lib/systemd/system/kodi.service
[Unit]
Description=Kodi standalone (GBM)
After=remote-fs.target systemd-user-sessions.service network-online.target nss-lookup.target sound.target bluetooth.target polkit.service upower.service mysqld.service
Wants=network-online.target polkit.service upower.service
Conflicts=getty@tty1.service

[Service]
User=kodi
Group=kodi
EnvironmentFile=-/etc/conf.d/kodi-standalone
PAMName=login
TTYPath=/dev/tty1
ExecStart=/usr/bin/kodi-standalone
ExecStop=/usr/bin/killall --user kodi --exact --wait kodi.bin
Restart=on-abort
StandardInput=tty
StandardOutput=journal

[Install]
Alias=display-manager.service


and the the status of the running service looks like this:

Code: Select all
* kodi.service - Kodi standalone (GBM)
     Loaded: loaded (/usr/lib/systemd/system/kodi.service; disabled; vendor preset: disabled)
     Active: active (running) since Thu 2022-01-06 17:03:26 CET; 20h ago
   Main PID: 1072 (kodi-standalone)
      Tasks: 0 (limit: 1567)
        CPU: 33ms
     CGroup: /system.slice/kodi.service
             > 1072 /bin/sh /usr/bin/kodi-standalone

Jan 06 17:03:26 kodi systemd[1]: Started Kodi standalone (GBM).
Jan 06 17:03:26 kodi systemd[1072]: pam_systemd_home(login:account): systemd-homed is not available: Unit dbus-org.freede>
Jan 06 17:03:26 kodi systemd[1072]: pam_unix(login:session): session opened for user kodi(uid=1000) by (uid=0)
Jan 06 17:03:26 kodi systemd[1072]: pam_env(login:session): deprecated reading of user environment enabled
Jan 06 18:07:41 kodi kodi-standalone[2598]: Can't open display
Jan 06 20:13:53 kodi kodi-standalone[10105]: Can't open display


So it seems that for ArchLinuxARM, the (GBM standalone) service is running in system.slice and not in user.slice as it supposedly would on a regular ArchLinux (I can't verify this right now). From within Kodi, using the reboot/shutdown options in the GUI works, the exit option crashes Kodi unfortunately and also deactivates the video output:

Code: Select all
x kodi.service - Kodi standalone (GBM)
     Loaded: loaded (/usr/lib/systemd/system/kodi.service; disabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Fri 2022-01-07 13:59:03 CET; 1min 19s ago
    Process: 367 ExecStart=/usr/bin/kodi-standalone (code=exited, status=0/SUCCESS)
    Process: 492 ExecStop=/usr/bin/killall --user kodi --exact --wait kodi.bin (code=exited, status=1/FAILURE)
   Main PID: 367 (code=exited, status=0/SUCCESS)
        CPU: 70ms

Jan 07 13:58:27 kodi systemd[1]: Started Kodi standalone (GBM).
Jan 07 13:58:27 kodi systemd[367]: pam_systemd_home(login:account): systemd-homed is not available: Unit dbus-org.freedesktop.home1.service not found.
Jan 07 13:58:27 kodi systemd[367]: pam_unix(login:session): session opened for user kodi(uid=1000) by (uid=0)
Jan 07 13:58:27 kodi systemd[367]: pam_env(login:session): deprecated reading of user environment enabled
Jan 07 13:59:03 kodi systemd[492]: pam_systemd_home(login:account): systemd-homed is not available: Unit dbus-org.freedesktop.home1.service not found.
Jan 07 13:59:03 kodi systemd[492]: pam_unix(login:session): session opened for user kodi(uid=1000) by (uid=0)
Jan 07 13:59:03 kodi systemd[492]: pam_env(login:session): deprecated reading of user environment enabled
Jan 07 13:59:03 kodi systemd[1]: kodi.service: Control process exited, code=exited, status=1/FAILURE
Jan 07 13:59:03 kodi systemd[1]: kodi.service: Failed with result 'exit-code'.


So how can I properly stop the kodi.service

  1. from the CLI
  2. from the GUI (exit option)

having Kodi exit gracefully? I would really like to be able to stop Kodi both from the CLI and from within the GUI and use the Raspberry Pi afterwards without having to reboot inbetween.

Thanks.
blablubb1234
 
Posts: 12
Joined: Fri Jan 07, 2022 3:18 pm

Re: How to properly stop Kodi on a Raspberry Pi 3 Model B?

Postby graysky » Fri Jan 07, 2022 3:33 pm

1. Run systemctl stop kodi
2. I do not know how to have the service exit with a 0 status. But stopping it from the GUI (Power menu>Ext) results in the expected end of the kodi process and display of console login prompt.
graysky
 
Posts: 1378
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: How to properly stop Kodi on a Raspberry Pi 3 Model B?

Postby blablubb1234 » Fri Jan 07, 2022 4:20 pm

graysky wrote:1. Run systemctl stop kodi
2. I do not know how to have the service exit with a 0 status. But stopping it from the GUI (Power menu>Ext) results in the expected end of the kodi process and display of console login prompt.

Regarding 1.: I know of course that I can stop the service in this way. I asked specifically because of the inconsistency between the wiki entry and the reality of the service unit provided in the ARM package. Is there no down-side to stopping using systemctl?

Regarding 2.: Hm.. and is there a way that on quitting via GUI I get back to the terminal? Or provided there isn't, get a new terminal? At the moment all I can do is PuTTY into Arch and reboot, which is not very convenient.
blablubb1234
 
Posts: 12
Joined: Fri Jan 07, 2022 3:18 pm

Re: How to properly stop Kodi on a Raspberry Pi 3 Model B?

Postby graysky » Fri Jan 07, 2022 7:08 pm

blablubb1234 wrote:Regarding 1.: I know of course that I can stop the service in this way. I asked specifically because of the inconsistency between the wiki entry and the reality of the service unit provided in the ARM package. Is there no down-side to stopping using systemctl?


There was a typo on the wiki now corrected. Bottom line: if you [b]systemctl reboot[/b[ you will lose data as kodi gets taken down ungracefully by systemd just like other applications like X. If you're logged into an Xsession, and someone executes the same command, you too will lose data as X is killed without prompting you to save your work.

To avoid that, use the recommended methods to reboot/shutdown. These all have one thing in common, they let kodi drive the call to reboot or to shutdown which does end gracefully.

blablubb1234 wrote:Regarding 2.: Hm.. and is there a way that on quitting via GUI I get back to the terminal? Or provided there isn't, get a new terminal? At the moment all I can do is PuTTY into Arch and reboot, which is not very convenient.


On my system, selecting "exit" drops it down to the state the machine was in prior. I do have to change TTYs to be able to type. Ctrl+F2 for example. Kodi will use TTY1 by default.
graysky
 
Posts: 1378
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: How to properly stop Kodi on a Raspberry Pi 3 Model B?

Postby blablubb1234 » Fri Jan 07, 2022 10:26 pm

gravsky wrote:
blablubb1234 wrote:
Regarding 1.: I know of course that I can stop the service in this way. I asked specifically because of the inconsistency between the wiki entry and the reality of the service unit provided in the ARM package. Is there no down-side to stopping using systemctl?

There was a typo on the wiki now corrected. Bottom line: if you [b]systemctl reboot[/b[ you will lose data as kodi gets taken down ungracefully by systemd just like other applications like X. If you're logged into an Xsession, and someone executes the same command, you too will lose data as X is killed without prompting you to save your work.

To avoid that, use the recommended methods to reboot/shutdown. These all have one thing in common, they let kodi drive the call to reboot or to shutdown which does end gracefully.

Thanks first of all for pointing out and correcting the typo in the wiki, appreciated. Note however that I was never talking about shutting down or rebooting the Raspberry Pi itself using systemctl. Like I said in my opening post: Both shut down and reboot works well from the GUI and from the CLI (without Kodi running).

The question was and is how I get to that state :)

gravsky wrote:
blablubb1234 wrote:
Regarding 2.: Hm.. and is there a way that on quitting via GUI I get back to the terminal? Or provided there isn't, get a new terminal? At the moment all I can do is PuTTY into Arch and reboot, which is not very convenient.


On my system, selecting "exit" drops it down to the login prompt as before. I do have to change TTYs to be able to type. Ctrl+F2 for example. Kodi will use TTY1 by default.

Okay, but I usually don't have a keyboard connected to the Raspberry Pi, so when I exit from the GUI, the video output stops (probably because TTY1 is closed) and I don't see any login prompt. Even if I then PuTTY/SSH into the system and start the Kodi service again, there's no video output on screen. Is there a smart/recommended way to change this behaviour?

And: Do I understand correctly that sudo systemctrl stop kodi.service then is in fact an appropriate way to stop Kodi gracefully?

Thanks and regards.
blablubb1234
 
Posts: 12
Joined: Fri Jan 07, 2022 3:18 pm

Re: How to properly stop Kodi on a Raspberry Pi 3 Model B?

Postby graysky » Fri Jan 07, 2022 11:08 pm

Yes, to stop kodi gracefully use systemctl. I misread or misunderstood.
graysky
 
Posts: 1378
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: How to properly stop Kodi on a Raspberry Pi 3 Model B?

Postby blablubb1234 » Fri Jan 07, 2022 11:58 pm

gravsky wrote:Yes, to stop kodi gracefully use systemctl. I misread or misunderstood.

Thanks for clarifying. No worries, could be my expression as well :D

blablubb1234 wrote:Regarding 2.: Hm.. and is there a way that on quitting via GUI I get back to the terminal? Or provided there isn't, get a new terminal? At the moment all I can do is PuTTY into Arch and reboot, which is not very convenient.

Anything on this one? Like starting the kodi.service in a different way or editing the service unit itself? I know too little about systemd unfortunately :?
blablubb1234
 
Posts: 12
Joined: Fri Jan 07, 2022 3:18 pm

Re: How to properly stop Kodi on a Raspberry Pi 3 Model B?

Postby graysky » Sat Jan 08, 2022 11:22 am

I do not know. What do you see when you exit now? Why do you care if you do not have a keyboard connected? If you do connect one, just this Ctrl+F2 to get a login prompt.
graysky
 
Posts: 1378
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: How to properly stop Kodi on a Raspberry Pi 3 Model B?

Postby blablubb1234 » Sat Jan 08, 2022 8:21 pm

gravsky wrote:I do not know. What do you see when you exit now? Why do you care if you do not have a keyboard connected? If you do connect one, just this Ctrl+F2 to get a login prompt.
Well, actually now I see what I wanted all along when using the Exit option of the Kodi GUI: The terminal :) I don't know why it's showing up now, probably I made some stupid mistake before. And I did care because even though I usually PuTTY into the system, (in some cases) it's still nice to have some immediate feedback on screen.

Topic can be closed.
blablubb1234
 
Posts: 12
Joined: Fri Jan 07, 2022 3:18 pm

Re: How to properly stop Kodi on a Raspberry Pi 3 Model B?

Postby grandcanyon » Tue Jan 18, 2022 2:00 am

kodi_standalone is designed not to go into a shell on exit. Are you logging in as kodi or another user? I believe if you change the user and group to your login user and change the command to just kodi it should take you to shell on exit. If you login and then manually type kodi this will take you back to a shell prompt for sure as this is how I have mine setup while I work on it,
grandcanyon
 
Posts: 20
Joined: Tue Jan 18, 2022 1:46 am


Return to ARMv7h

Who is online

Users browsing this forum: No registered users and 5 guests