I'm using this definition for a systemd
job:
[Unit]
Description=Some job
[Service]
ExecStart=/usr/local/sbin/somejob
User=dlt
Type=forking
[Install]
WantedBy=multi-user.target
The script is called is as follows (calling a simple routine that listens on a tcpip socket and appends the input to a file):
#!/bin/sh
cd /home/user/tmp/testout
nohup java -jar /home/user/programming/tests/java/core/SocketTest/SocketTest.jar </dev/null >/dev/null &
After systemctl start somejob
process shows as running, with init
as its parent:
user@CANTANDO ~$ ps -u dlt eo pid,ppid,command
PID PPID COMMAND
8718 1 java -jar /home/user/programming/tests/java/core/SocketTest/SocketTest.jar
After performing systemctl stop somejob
the process doesn't show anymore (and the port is closed).
So everything seems fine and dandy
My question is: Is this an acceptable solution for running a java daemon with systemd
, or are there caveats, and thus other more stable or secure ways to go about achieving this?