반응형
Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 봉화 숲속캠핑장
- ssd 포맷
- RDEPENDS
- udpsink
- yocto
- Jetson
- l4t
- nvidia
- gstsample
- vpi
- cpu frequency
- meta-tegra
- bitbake
- nvarguscamerasrc
- 오블완
- bash
- boot process
- 티스토리챌린지
- gcc7
- mkfs.ext4
- lineedit
- vpiimage
- libargus api
- LAYERS
- server error
- /dev/kmsg
- orin nx
- linux
- camera
- libargus
Archives
- Today
- Total
DREAMER
[service] Auto-restart a failed service in systemd 본문
728x90
반응형
AP: NVIDIA Jetson Nano
Kernel: 4.14
연결된 블루투스 장치가 특정이유로 connected, disconnected를 반복하다보면 Agent registered라고 뜨며, bluetoothd이 죽는 경우가 발생한다. (Segmentation fault, SIGSEGV(11) 발생)
이 때 bluetooth.service의 status는 Failed이다.
단순히 bluetooth.service를 restart하면 되지만, 다음과 같이 service 설정을 변경하면, failed시 자동으로 restart를 한다.
보통 아래와 같이 bluetooth.service가 생성되어있을 것이다.
$ cat /lib/systemd/system/bluetooth.service
[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth
[Service]
Type=dbus
BusName=org.bluez
ExecStart=/usr/lib/bluetooth/bluetoothd
NotifyAccess=main
#WatchdogSec=10
#Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
ProtectHome=true
ProtectSystem=full
[Install]
WantedBy=bluetooth.target
Alias=dbus-org.bluez.service
Restart와 RestartSec를 설정해준다. RestartSec의 기본 값은 5s이다.
[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth
[Service]
Type=dbus
BusName=org.bluez
ExecStart=/usr/lib/bluetooth/bluetoothd
NotifyAccess=main
#WatchdogSec=10
Restart=on-failure # comment for auto-restart when failed
RestartSec=2s # set restart time to 2sec
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
ProtectHome=true
ProtectSystem=full
[Install]
WantedBy=bluetooth.target
Alias=dbus-org.bluez.service
장치 재부팅 후 bluetooth.service에 대한 설정 값들을 확인할 수 있다.
$ systemctl show bluetooth
$ systemctl show bluetooth | grep Restart
Restart=on-failure
RestartUSec=2s
NRestarts=0
실제로 restart하는지 확인하고 싶다면, bluetoothd가 똑같은 예외를 발생하여 종료하게 하면 된다.
$ ps -ef | grep bluetoothd
$ kill -11 [bluetoothd pid]
예)
$ ps -ef | grep bluetoothd
4800 bluetoothd
$ kill -11 4800
설정한 시간에 맞춰 restart를 하는 것을 알 수 있다.
728x90
반응형
'프로그래밍 > Linux' 카테고리의 다른 글
[date] system clock, 날짜, 시간 변경 (0) | 2023.06.01 |
---|---|
[Bash] CPU 온도 값을 출력하는 bash shell (0) | 2023.05.31 |
[signal] Signal numbers (0) | 2023.05.17 |
[patch] patch 파일 생성 및 적용 (0) | 2023.05.09 |
[systemd] service 생성 및 추가 (0) | 2023.04.18 |
Comments