Hi,
Finally I deploy a jar.
First I create a user and a group with home directory for this user with out login shell.
I put my jar file in this home and I create system service in, /etc/systemd/system/genedatabank.service, to start my application like this:
If I start the application with systemctl start genedatabank.service application start but not create/have access to directory .jmix/work and if I start with sudo -u genedatabank java -jar genedatabank.jar --server.port=8090 in directory /opt/genedatabank application start and can create/have access to .jmix/work...
Now work great, this solution I like more because is elegant.
florin@server:~$ cat /etc/systemd/system/genedatabank.service
[Unit]
Description=GeneDataBank java server application
# depend by network and postgres
Wants=network-online.target postgresql.service
# start after network and postgres service start
After=network-online.target postgresql.service
[Service]
# run as user genedatabank (need to exist before)
User=genedatabank
# from group genedatabank (need to exist before)
Group=genedatabank
# restart always
Restart=always
# activation state
Type=simple
# working directory for user (in this case the home is /opt/genedatabank)
WorkingDirectory=/opt/genedatabank/
# execute command to start the application
ExecStart=/usr/lib/jvm/java-17-openjdk-amd64/bin/java \
-jar /opt/genedatabank/genedatabank.jar \
--server.port=8090
# send stdout to syslog
StandardOutput=syslog
# send stderr to syslog
StandardError=syslog
# identifier for syslog
SyslogIdentifier=genedatabank
[Install]
WantedBy=multi-user.target