Spring/Spring Boot

[Spring Boot] CentOS에 서비스 등록하기

은쑥이 2021. 6. 7. 11:02

00. 실행환경

CentOS7

 

01. Service 파일 생성

$ nano /etc/systemd/system/서비스명.service

 

02. Service 내용 작성

[Unit]
Description=Java Application Service
After=network.target

[Service]
ExecStart=/bin/bash -c "exec java -Dspring.profiles.active=DEV1 -jar /root/서비스.jar"

User=root
Group=root

[Install]
WantedBy=multi-user.target

 

03. Service 생성

$ systemctl enable 서비스명.service

 

04. Service 실행

$ systemctl start 서비스명    // 서비스 시작
$ systemctl stop 서비스명    // 서비스 종료

 

05. Service 상태 확인

$ systemctl status 서비스명