Create as .sh file add jar execution command
/usr/bin/java -jar /u01/api/docuchat-api-0.0.1.jar --spring.config.location=file:/u01/api/config/ > /u01/api/logs/springboot.log
in you case you can use only /usr/bin/java -jar jarname.jar
Create .service file under /etc/systemd/system/ folder
my file name: dora-api-demo.service
Script is below
[Unit]
Description=dora-demo-api
[Service]
User=root
WorkingDirectory=/usr/local/bin
ExecStart=/usr/bin/bash /u01/api/dora-service.sh
SuccessExitStatus=0
[Install]
WantedBy=multi-user.target
once the script is passed inside the dora-api-demo.service file
need use below command to
sudo systemctl daemon-reload
sudo systemctl enable dora-api-demo
sudo systemctl start dora-api-demo (To start the service)
sudo systemctl status dora-api-demo (To check the status of the service)
sudo systemctl stop dora-api-demo (to stop the service)
sudo systemctl restart dora-api-demo (to restart the service)
No comments:
Post a Comment