Rocky Linux Spring Service 등록하기
# cd /etc/systemd/system/
# vi [servicename].service
[Unit]
Description=api gateway
Wants=network-online.target
After=network-online.target
[Service]
User=root
ExecStart=/bin/bash -c "exec java -Xms4G -Xmx4G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=log_path/heapdump.hprof -jar -DSpring.profiles.active=prod {service_path}/{service_name}.jar"
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
특정 java 버전으로 실행하도록 해야 할 때
[Unit]
Description=api gateway
Wants=network-online.target
After=network-online.target
[Service]
User=root
Environment="JAVA_HOME=/usr/lib/jvm/temurin-17-jdk"
ExecStart=/bin/bash -c "exec ${JAVA_HOME}/bin/java -Xms4G -Xmx4G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=log_path/heapdump.hprof -jar -DSpring.profiles.active=prod {service_path}/{service_name}.jar"
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
start
systemctl enable [servicename]
systemctl daemon-reload
systemctl start [servicename]
systemctl status [servicename]
remove service
systemctl stop [servicename]
systemctl disable [servicename]
rm /etc/systemd/system/[servicename]
rm /etc/systemd/system/[servicename] # and symlinks that might be related
rm /usr/lib/systemd/system/[servicename]
rm /usr/lib/systemd/system/[servicename] # and symlinks that might be related
systemctl daemon-reload
systemctl reset-failed
댓글남기기