Page 1 of 2

UMS is not stopping

Posted: Tue Mar 07, 2023 8:55 am
by MetaRZA
System: AlmaLinux 8
Version: UMS 13.2.0
Java: java-1.8.0-openjdk-1.8.0.362.b09-2.el8_7.x86_64

UMS is started via systemd (systemctl start ums) (see attachment).

When I stop the service (systemctl stop ums) it will always hang for 1m30s and then use SIGKILL to kill the process.

After which I see (systemctl status -l ums)

Code: Select all

� ums.service - Universal Media Server
   Loaded: loaded (/etc/systemd/system/ums.service; enabled; vendor preset: disabled)
   Active: failed (Result: timeout) since Mon 2023-03-06 15:42:03 EST; 7min ago
  Process: 20999 ExecStop=/usr/bin/pkill --signal SIGINT -f java .*ums.jar.* (code=exited, status=0/SUCCESS)
  Process: 20354 ExecStart=/opt/ums/startup.sh (code=killed, signal=KILL)
 Main PID: 20354 (code=killed, signal=KILL)

Mar 06 15:39:39 henry.localdomain systemd[1]: Started Universal Media Server.
Mar 06 15:40:33 henry.localdomain systemd[1]: Stopping Universal Media Server...
Mar 06 15:42:03 henry.localdomain systemd[1]: ums.service: State 'stop-sigterm' timed out. Killing.
Mar 06 15:42:03 henry.localdomain systemd[1]: ums.service: Killing process 20354 (java) with signal SIGKILL.
Mar 06 15:42:03 henry.localdomain systemd[1]: ums.service: Main process exited, code=killed, status=9/KILL
Mar 06 15:42:03 henry.localdomain systemd[1]: ums.service: Failed with result 'timeout'.
Mar 06 15:42:03 henry.localdomain systemd[1]: Stopped Universal Media Server.
This means turnning off my media server takes an extra 1m30s, which could be a problem during a blackout.

Anyone have an idea on why UMS doesn't stop when asked politely?

Re: UMS is not stopping

Posted: Wed Mar 08, 2023 7:35 am
by mik_s
I don't know anything about the shutdown sequence but it has been a problem for a while.

Usually I see errors in logs due to the ports or database still being in use when trace logs are generated because when UMS is restarted as a new process the old one is still shutting down and still using them.

I think a part of that is to make sure everything has fully completed its process to prevent any corruption to the database and to inform everything on the network that it is shutting down. I'm sure this could be optimised better as the library scanner was still working at the end of the logs.

Re: UMS is not stopping

Posted: Thu Mar 09, 2023 1:13 pm
by MetaRZA
It occurred to me that I am the Programmer Born, so I grabbed the source code from git, recompiled and ran that. Using 13.2.1-SNAPSHOT, UMS shuts down correctly.

The jre17 shipping with 13.2.0 (BellSoft 17.0.5, 2022-10-18) is different from the jre17 I compiled with (BellSoft 17.0.6, 2023-01-17).

Next step, compile 13.2.0 and see if problem returns.

Re: UMS is not stopping

Posted: Thu Mar 09, 2023 1:53 pm
by boss
I run UMS on a headless Gentoo Linux server.
My system java is always kept up to date.
I always modify UMS.sh so UMS uses my system java and not the UMS supplied java.

In UMS.sh change:
# Use our JVM if it exists
if [ -f jre17/bin/java ]; then
JAVA="jre17/bin/java"
fi

To:
# Use our JVM if it exists
#if [ -f jre17/bin/java ]; then
# JAVA="jre17/bin/java"
#fi

Re: UMS is not stopping

Posted: Thu Mar 09, 2023 3:13 pm
by MetaRZA
UMS 13.2.0 compiled with JRE17.0.6+10 shuts down correctly.
UMS 13.2.0 compiled with JRE17.0.5+8 shuts down correctly.
I reinstalled UMS from UMS-13.2.0-x86_64.tgz and now it shuts down correctly.
I tried precompiled UMS using a system java (bellsoft-java17) and it shuts down correctly.
I tried precompiled UMS using a system java (java-19-openjdk-19.0.2.0.7-1.rolling.el8) and it shuts down correctly.
Unfortunately I managed to muck up my initial install of UMS. The one that was causing the problem.

In other words, I'm now unable to reproduce the problem.

Re: UMS is not stopping

Posted: Thu Mar 09, 2023 3:16 pm
by MetaRZA
boss wrote: Thu Mar 09, 2023 1:53 pm In UMS.sh change:
A better way to do this is to just move the jre17 directory out of the way :

Code: Select all

cd /dir/you/installed/ums/in
mv jre17 jre17-NOT
You can confirm which JRE is being used with lsof :

Code: Select all

lsof -c java | grep libjavajpeg

Re: UMS is not stopping

Posted: Thu Mar 09, 2023 3:36 pm
by mik_s
MetaRZA wrote: Thu Mar 09, 2023 3:13 pm In other words, I'm now unable to reproduce the problem.
I hate it when that happens. You find a problem and go tracking it down until you accidentally fix it and are unable to reproduce :x

On the plus side it is now working as intended :D

Re: UMS is not stopping

Posted: Thu Mar 09, 2023 5:26 pm
by boss
A better way to do this is to just move the jre17 directory out of the way :

Either way has the same end result.
I prefer to modify UMS.sh to prevent UMS even checking for the UMS java version in the first place.

Re: UMS is not stopping

Posted: Fri Mar 10, 2023 7:28 am
by MetaRZA
boss wrote: Thu Mar 09, 2023 5:26 pm I prefer to modify UMS.sh to prevent UMS even checking for the UMS java version in the first place.
Fair enough.

I'm curious as to why you want to use the system Java and not the one shipped by UMS.

Re: UMS is not stopping

Posted: Fri Mar 10, 2023 11:08 am
by boss
The main reason I like to use my system java is because I do any updates on my server once a week.
Java with UMS is V17.0.5 and my system java is V17.0.6.

It's not a big deal but sometimes the java version included with UMS can be quite a bit older.