Linux/Ubuntu
[Ubuntu] apache2.service failed with result 'timeout' / apache2 재실행 설정
이나피스
2024. 4. 15. 10:50
반응형
서버가 죽어서 로그를 확인해보니 timeout으로 서버가 죽어 있었다
서버가 죽을때 restart 해주는 설정을 해주자
restart 설정은 no, always, on-sucess, on-failure, on-abnormal, on-abort, on-watchdog가 존재하는데
각각 restart 기준은 아래 comman드 실행시 나오는 문서의 Restart= 부분에서 확인 가능하다
$ LANG=C man systemd.service
예를 들어 no로 설정할 경우 재실행은 이루어지지 않으며, always로 설정시 모든 경우에서 재실행이 된다고 보면 된다
그럼 현재 내 서버는 어떤 설정인지 확인해보자
$ less /usr/lib/systemd/system/apache2.service
Restart 설정이 되어있지만 on-abort로 설정되어있다
즉 Unclean signal일 경우만 자동으로 재실행해주는것이다
timeout을 재실행 해주는 설정은 always, on-failure, on-abnormal
그 중 나는 on-failure로 설정해주겠다
apache2.service에서 수정해도 되지만 업데이트 등 변경될 가능성이 있기때문에
systemctl edit으로 내용을 재정의해준다
$ sudo systemctl edit apache2
### Editing /etc/systemd/system/apache2.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file
### Lines below this comment will be discarded
### /lib/systemd/system/apache2.service
# [Unit]
# Description=The Apache HTTP Server
# After=network.target remote-fs.target nss-lookup.target
# Documentation=https://httpd.apache.org/docs/2.4/
#
# [Service]
# Type=forking
# Environment=APACHE_STARTED_BY_SYSTEMD=true
# ExecStart=/usr/sbin/apachectl start
# ExecStop=/usr/sbin/apachectl graceful-stop
# ExecReload=/usr/sbin/apachectl graceful
# KillMode=mixed
# PrivateTmp=true
Restart=on-failure
#
# [Install]
# WantedBy=multi-user.target
끝
참고자료
https://www.netassist.ne.jp/techblog/29324/
不正終了するApacheを自動で起動させる|株式会社ネットアシスト
はじめにこんにちは、技術部のTUです!Apacheが夜間に勝手に不正終了してしまう、コマンドで起動は出来るし設定も間違っていないに・・・という事は無いでしょうか?そんな時に役立つsyste
www.netassist.ne.jp
반응형