[systemd-devel] Cannot make java exit 0 on SIGTERM
Lennart Poettering
lennart at poettering.net
Thu Dec 15 07:56:32 PST 2011
On Mon, 28.11.11 15:12, Chris Paulson-Ellis (chris at edesix.com) wrote:
> Hi,
>
> I'm running a Java JVM service using:
>
> ExecStart=/usr/bin/java -jar foo.jar
>
> When I stop the service with systemctl, it goes into the failed
> state because the JVM exits with status 143 instead of 0.
>
> There doesn't seem to be any way to get a JVM to exit(0) on SIGTERM.
> You can run code on the signal with Runtime.addShutdownHook(), but
> you cannot call Runtime.exit(0) from within a shutdown hook, so you
> cannot influence the exit status.
>
> Is there any way to get systemd to treat the 143 exit status as
> normal termination if it sent a SIGTERM? I'd rather not write a
> signal catching C or shell-script wrapper around the JVM as I'll
> probably introduce a race condition or other error.
Use ExecStart=-/usr/bin/java... (i.e. add the - in there, to ignore
failure exit codes)
Lennart
--
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel
mailing list