본문 바로가기

OS (Operating System)/Linux

리눅스 (Linux) 내장형 톰캣, War파일 서비스 등록, War Service Ubuntu

728x90
ssh -p 22 test@192.168.100.200

ssh로 우분투 접속

sudo vi /etc/systemd/system/temp.service

service 파일 생성

 

[Unit]
Description=Weather Collect Service
After=network.target

[Service]
Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"
WorkingDirectory=/home/test/
ExecStart=/bin/bash -c "exec java -jar temp.war"
#ExecStart=/bin/bash -c "exec java -jar -Dspring.profiles.active=dev temp.war"

Restart=on-abnormal
RestartSec=10

User=root
Group=root

[Install]
WantedBy=multi-user.target

경로설정, 저장

WorkingDirectory가 temp.war가 들어있는 폴더 

Dspring.profiles.active=  는 war 내 .yml 선택용

 

//reload
systemctl daemon-reload

//service 활성화
systemctl enable temp

//server 실행
systemctl start temp

//server 상태확인
systemctl status temp

 

active running 성공

 

 

 

추가명령어

//server종료
systemctl stop tomcat
//service 비활성화
systemctl disable tomcat
728x90