E
E
Evgeny Elizarov2014-11-30 12:10:45
linux
Evgeny Elizarov, 2014-11-30 12:10:45

How to write a service file to start a java process?

Gentlemen, the question is, you need to write a service file to start the JAVA process, everything seems to work, but the feeling is that systemctl does not get some kind of answer from the script that it needs and the process dies.
# cat airvideoserver.service

[Unit]
Description=AirVideoServer
After=syslog.target
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/java -jar /usr/local/AirVideo/AirVideoServerLinux.jar /usr/local/AirVideo/airvideoserver.conf > /dev/null 2>&1 &
User=root
ExecStop=/bin/kill -TERM $MAINPID
TimeoutSec=300

[Install]
WantedBy=multi-user.target

After systemctl start airvideoserver the console hangs, the process runs for about a minute, after which Job for airvideoserver.service failed appears in the console. See 'systemctl status airvideoserver.service' and 'journalctl -xn' for details. and the process dies.
I look at the log, I see the normal operation of the Java application, after which "airvideoserver.service operation timed out. Terminating."
# journalctl -xn
-- Logs begin at Sun 2014-11-30 11:49:37 MSK, end at Sun 2014-11-30 12:05:44 MSK. --
Nov 30 12:05:21 airvideoserver.korphome.local java[2801]: DEBUG: SegmentedEncoder: frame= 1179 fps= 27 q=20.0 size= 13108kB time=47.13 bitrate=2278.4kbits/s dup=0 drop=3
Nov 30 12:05:26 airvideoserver.korphome.local java[2801]: DEBUG: SegmentedEncoder: frame= 1316 fps= 27 q=22.0 size= 14871kB time=52.84 bitrate=2305.3kbits/s dup=0 drop=3
Nov 30 12:05:31 airvideoserver.korphome.local java[2801]: DEBUG: SegmentedEncoder: frame= 1453 fps= 27 q=25.0 size= 16702kB time=58.56 bitrate=2336.5kbits/s dup=0 drop=3
Nov 30 12:05:36 airvideoserver.korphome.local java[2801]: DEBUG: SegmentedEncoder: frame= 1607 fps= 27 q=25.0 size= 18682kB time=64.98 bitrate=2355.2kbits/s dup=0 drop=3
Nov 30 12:05:42 airvideoserver.korphome.local java[2801]: DEBUG: SegmentedEncoder: frame= 1758 fps= 27 q=22.0 size= 20646kB time=71.28 bitrate=2372.8kbits/s dup=0 drop=3
Nov 30 12: 05:44 airvideoserver.korphome.local systemd[1]: airvideoserver.service operation timed out. Terminating.
Nov 30 12:05:44 airvideoserver.korphome.local java[2801]: DEBUG: SegmentedEncoder: frame= 1917 fps= 28 q=25.0 size= 22708kB time=77.91 bitrate=2387.7kbits/s dup=0 drop=3
Nov 30 12:05:44 airvideoserver.korphome.local systemd[1]: airvideoserver.service: control process exited, code=exited status=143
Nov 30 12:05:44 pm airvideoserver.korphome.local systemd[1]: Failed to start AirVideoServer.

What response from systemd script is missing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
brutal_lobster, 2014-12-02
@brutal_lobster

www.freedesktop.org/software/systemd/man/systemd.s...

Specifically, redirection using "<", "<<", ">", and ">>", pipes using "|", running programs in the background using "&", and other elements of shell syntax are not supported.

V
Vladislav Gasanov, 2014-12-22
@kosmoflyko

We use Apache Common Daemon commons.apache.org/proper/commons-daemon

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question