명백한 이유없이 systemd 서비스가 다시 시작됩니다.

명백한 이유없이 systemd 서비스가 다시 시작됩니다.

두 개의 Spring 애플리케이션이 정상적으로 실행 중인데 특별한 일이 발생하지 않았는데 갑자기 애플리케이션이 다시 시작되면 Journalctl이 다음 줄을 표시합니다.

Jan 15 04:43:11 nyota.softworks.nl systemd[1]: Stopping calendaraggregator.service...
Jan 15 04:43:11 nyota.softworks.nl systemd[1]: calendaraggregator.service: Deactivated successfully.
Jan 15 04:43:11 nyota.softworks.nl systemd[1]: Stopped calendaraggregator.service.
Jan 15 04:43:11 nyota.softworks.nl systemd[1]: calendaraggregator.service: Consumed 3min 313ms CPU time.
Jan 15 04:43:11 nyota.softworks.nl systemd[1]: Started calendaraggregator.service.
Jan 15 10:41:43 nyota.softworks.nl systemd[1]: Stopping calendaraggregator.service...
Jan 15 10:41:43 nyota.softworks.nl systemd[1]: calendaraggregator.service: Deactivated successfully.
Jan 15 10:41:43 nyota.softworks.nl systemd[1]: Stopped calendaraggregator.service.
Jan 15 10:41:43 nyota.softworks.nl systemd[1]: calendaraggregator.service: Consumed 1min 48.505s CPU time.
Jan 15 10:41:43 nyota.softworks.nl systemd[1]: Started calendaraggregator.service.
Jan 15 18:17:17 nyota.softworks.nl systemd[1]: Stopping calendaraggregator.service...
Jan 15 18:17:17 nyota.softworks.nl systemd[1]: calendaraggregator.service: Deactivated successfully.
Jan 15 18:17:17 nyota.softworks.nl systemd[1]: Stopped calendaraggregator.service.
Jan 15 18:17:17 nyota.softworks.nl systemd[1]: calendaraggregator.service: Consumed 2min 24.748s CPU time.
Jan 15 18:17:17 nyota.softworks.nl systemd[1]: Started calendaraggregator.service.

그러나 systemctl 구성 AFAIK는 실패한 후에도 재부팅되지 않습니다(디버깅을 위해 꺼냈습니다).

[Service]
WorkingDirectory=/home/calendaraggregator/
User=calendaraggregator
Group=calendaraggregator
ExecStart=/bin/bash /home/calendaraggregator/run.sh

무엇이 종료를 촉발했는지 확인할 수 있는 방법이 있나요?

INFO org.springframework.core.log.CompositeLog [SpringApplicationShutdownHook] Stopping.응용 프로그램의 로그는 그다지 유용하지 않으며 단지 이유/예외가 없다고 말합니다 . 또한 기본 프로그램이 다시 호출되고(이 내용을 기록함) 내가 아는 한 systemd를 다시 시작하도록 구성하지 않았기 때문에 응용 프로그램이 외부에서 다시 시작됩니다.


업데이트 2024-02-10

많은 시도 끝에 이것은 복잡한 문제인 것 같습니다. 첫째, SpringBoot에는 실행기 또는 개발자 도구를 통해 내부 다시 시작 기능이 있습니다.

https://javapointers.com/spring/spring-boot/how-to-restart-spring-boot-automatically-using-actuator/

실행자는 빠른 작업을 수행하지 않지만 개발 도구에는 프로덕션 병에 몰래 들어가는 방법이 있습니다. 예를 들어 Maven Shade 플러그인을 사용하여 빌드합니다. 개발 도구가 활성화되는 것을 방지하려면 Java를 시작할 때 다음 옵션을 지정해야 합니다.

-Dspring.devtools.restart.enabled=false

그러나 그 이후에도 계속해서 재시작이 이루어지고 있습니다.

systemd 구성을 완전히 제거하고, 새로운 시작 셸 스크립트를 생성하고, 원래 시작 스크립트에 대한 호출만 기록한 후에 재부팅 문제가 사라졌습니다. 하지만 여전히 원래 시작 셸 스크립트가 호출되는 것을 볼 수 있습니다.

패치되었지만 해결되지 않았습니다. 원래 시작 스크립트를 계속 호출하는 것은 무엇입니까? !

답변1

이것은 공식적인 답변이 아니라 해결 방법입니다. systemd 서비스는 가능한 이유 없이 계속 다시 시작되지만 서비스를 사용자로 이동하면 더 이상 다시 시작되지 않는 것으로 나타났습니다.

https://wiki.archlinux.org/title/systemd/User#Example

관련 정보