systemctl

Custom Service 등둝

sudo vi /etc/systemd/system/sbapp.service
[Unit]
Description=sbapp
After=syslog.target network.target

[Service]
User=ec2-user
Group=ec2-user

ExecStart=/usr/bin/java -jar /home/ec2-user/app/sbapp.jar
ExecStop=/bin/kill -15 $MAINPID
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target
# 심볼릭 λ§ν¬λŠ” λ¦¬λˆ…μŠ€ λ ˆκ±°μ‹œ 방법(Optional)
sudo ln -s /home/ec2-user/app/sbapp.jar /etc/init.d/sbapp

# μ„œλΉ„μŠ€ μ‹œμž‘
sudo systemctl start sbapp

# ν”„λ‘œμ„ΈμŠ€ 확인
pgrep java

# μ„œλΉ„μŠ€ μƒνƒœ 확인
sudo systemctl status sbapp

# μž¬μ‹œμž‘
sudo systemctl restart sbapp

# λ¦¬λˆ…μŠ€ λΆ€νŒ…μ‹œ μžλ™ μ‹œμž‘
sudo systemctl enable sbapp

ref

What Else?
inflearn react api server -50% 할인쿠폰: 15108-f2af1e086101 buy me a coffee