systemctl
- sudo(root) κΆν νμ
systemctl status <service>
systemctl start <service>
systemctl stop <service>
systemctl restart <service>
systemctl enable <service>
Custom Service λ±λ‘
- spring boot μ
- systemd μ 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