From 9fefea2401df49d9be52f01ac8990c483a7b21e4 Mon Sep 17 00:00:00 2001
From: Francesco Pham <francesco.pham@huawei.com>
Date: Tue, 11 Apr 2023 15:45:14 +0200
Subject: [PATCH] openharmony-standard: restart systemd services on failures

Adding `Restart=on-failure` to all openharmony services

weston service is hanging at startup (SIGHUP) on raspberrypi4-64
adding `Restart=always` to systemd unit to restart
weston service when hanging. `Restart=on-failure` is not enough here.

Signed-off-by: Francesco Pham <francesco.pham@huawei.com>
---
 recipes-openharmony/openharmony/files/accesstoken.service      | 3 +++
 recipes-openharmony/openharmony/files/accountmgr.service       | 3 +++
 recipes-openharmony/openharmony/files/appspawn.service         | 3 +++
 recipes-openharmony/openharmony/files/deviceauth.service       | 3 +++
 recipes-openharmony/openharmony/files/distributed_data.service | 3 +++
 recipes-openharmony/openharmony/files/distributedsched.service | 3 +++
 recipes-openharmony/openharmony/files/dsoftbus.service         | 3 +++
 recipes-openharmony/openharmony/files/faultloggerd.service     | 3 +++
 recipes-openharmony/openharmony/files/foundation.service       | 3 +++
 recipes-openharmony/openharmony/files/hdcd.service             | 3 +++
 recipes-openharmony/openharmony/files/hilogd.service           | 3 +++
 recipes-openharmony/openharmony/files/hiview.service           | 3 +++
 recipes-openharmony/openharmony/files/huks.service             | 3 +++
 recipes-openharmony/openharmony/files/inputmethod.service      | 3 +++
 recipes-openharmony/openharmony/files/installs.service         | 3 +++
 recipes-openharmony/openharmony/files/media.service            | 3 +++
 recipes-openharmony/openharmony/files/mmi-uinput.service       | 3 +++
 recipes-openharmony/openharmony/files/multimodalinput.service  | 3 +++
 recipes-openharmony/openharmony/files/param.service            | 3 +++
 recipes-openharmony/openharmony/files/samgr.service            | 3 +++
 recipes-openharmony/openharmony/files/time.service             | 3 +++
 recipes-openharmony/openharmony/files/tokensync.service        | 3 +++
 recipes-openharmony/openharmony/files/weston.service           | 1 +
 23 files changed, 67 insertions(+)

diff --git a/recipes-openharmony/openharmony/files/accesstoken.service b/recipes-openharmony/openharmony/files/accesstoken.service
index 8d7956e5..50502bcc 100644
--- a/recipes-openharmony/openharmony/files/accesstoken.service
+++ b/recipes-openharmony/openharmony/files/accesstoken.service
@@ -8,6 +8,9 @@ Type=exec
 ExecStartPre=install -m 755 -d /data/service/e10/access_token
 # should run as system:system
 ExecStart=/usr/bin/sa_main /system/profile/accesstoken_service.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/accountmgr.service b/recipes-openharmony/openharmony/files/accountmgr.service
index 4b52a979..7b1aee34 100644
--- a/recipes-openharmony/openharmony/files/accountmgr.service
+++ b/recipes-openharmony/openharmony/files/accountmgr.service
@@ -15,6 +15,9 @@ Group=system
 SupplementaryGroups=shell
 LimitNICE=40
 ExecStart=/usr/bin/sa_main /system/profile/accountmgr.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/appspawn.service b/recipes-openharmony/openharmony/files/appspawn.service
index 52264e47..5994efbc 100644
--- a/recipes-openharmony/openharmony/files/appspawn.service
+++ b/recipes-openharmony/openharmony/files/appspawn.service
@@ -18,6 +18,9 @@ Environment="XKB_CONFIG_EXTRA_PATH=/etc/openharmony/xkb"
 ExecStartPre=install -m 0755 -d /run/openharmony/appspawn
 LimitNICE=40
 ExecStart=/usr/bin/appspawn
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/deviceauth.service b/recipes-openharmony/openharmony/files/deviceauth.service
index 106e75eb..4bb0da5d 100644
--- a/recipes-openharmony/openharmony/files/deviceauth.service
+++ b/recipes-openharmony/openharmony/files/deviceauth.service
@@ -15,6 +15,9 @@ Group=system
 SupplementaryGroups=shell
 LimitNICE=40
 ExecStart=/usr/bin/deviceauth_service
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/distributed_data.service b/recipes-openharmony/openharmony/files/distributed_data.service
index dc2e7c51..9e456bb5 100644
--- a/recipes-openharmony/openharmony/files/distributed_data.service
+++ b/recipes-openharmony/openharmony/files/distributed_data.service
@@ -16,6 +16,9 @@ SupplementaryGroups=shell readproc
 CapabilityBoundingSet=CAP_DAC_READ_SEARCH
 LimitNICE=40
 ExecStart=/usr/bin/sa_main /system/profile/distributeddata.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/distributedsched.service b/recipes-openharmony/openharmony/files/distributedsched.service
index e12863c3..d6fe5f5c 100644
--- a/recipes-openharmony/openharmony/files/distributedsched.service
+++ b/recipes-openharmony/openharmony/files/distributedsched.service
@@ -17,6 +17,9 @@ Group=system
 SupplementaryGroups=shell
 LimitNICE=40
 ExecStart=/usr/bin/sa_main /system/profile/distributedsched.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/dsoftbus.service b/recipes-openharmony/openharmony/files/dsoftbus.service
index dc8301aa..0c8351a0 100644
--- a/recipes-openharmony/openharmony/files/dsoftbus.service
+++ b/recipes-openharmony/openharmony/files/dsoftbus.service
@@ -19,6 +19,9 @@ Group=system
 SupplementaryGroups=shell
 LimitNICE=40
 ExecStart=/usr/bin/sa_main /system/profile/softbus_server.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/faultloggerd.service b/recipes-openharmony/openharmony/files/faultloggerd.service
index b9fb1811..4ab7b344 100644
--- a/recipes-openharmony/openharmony/files/faultloggerd.service
+++ b/recipes-openharmony/openharmony/files/faultloggerd.service
@@ -11,6 +11,9 @@ User=root
 Group=system
 SupplementaryGroups=log
 ExecStart=/usr/bin/faultloggerd
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/foundation.service b/recipes-openharmony/openharmony/files/foundation.service
index f2d255e1..620e1bd0 100644
--- a/recipes-openharmony/openharmony/files/foundation.service
+++ b/recipes-openharmony/openharmony/files/foundation.service
@@ -29,6 +29,9 @@ Group=system
 CapabilityBoundingSet=CAP_SYS_PTRACE CAP_KILL
 LimitNICE=40
 ExecStart=/usr/bin/sa_main /system/profile/foundation.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/hdcd.service b/recipes-openharmony/openharmony/files/hdcd.service
index 2c4f297f..92a243a1 100644
--- a/recipes-openharmony/openharmony/files/hdcd.service
+++ b/recipes-openharmony/openharmony/files/hdcd.service
@@ -8,6 +8,9 @@ After=param.service
 [Service]
 Type=exec
 ExecStart=/usr/bin/hdcd -t -l 3
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/hilogd.service b/recipes-openharmony/openharmony/files/hilogd.service
index 90dc7650..8fa85bcf 100644
--- a/recipes-openharmony/openharmony/files/hilogd.service
+++ b/recipes-openharmony/openharmony/files/hilogd.service
@@ -11,6 +11,9 @@ User=logd
 Group=log
 ExecStart=/usr/bin/hilogd
 ExecStartPost=hilog -G 16M
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/hiview.service b/recipes-openharmony/openharmony/files/hiview.service
index 16205d95..abaf406e 100644
--- a/recipes-openharmony/openharmony/files/hiview.service
+++ b/recipes-openharmony/openharmony/files/hiview.service
@@ -15,6 +15,9 @@ Group=system
 SupplementaryGroups=log
 LimitNICE=40
 ExecStart=/usr/bin/hiview
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 #[Install]
 #WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/huks.service b/recipes-openharmony/openharmony/files/huks.service
index 1fa0b8b6..24acafd9 100644
--- a/recipes-openharmony/openharmony/files/huks.service
+++ b/recipes-openharmony/openharmony/files/huks.service
@@ -13,6 +13,9 @@ Group=system
 SupplementaryGroups=shell
 LimitNICE=40
 ExecStart=/usr/bin/sa_main /system/profile/huks_service.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/inputmethod.service b/recipes-openharmony/openharmony/files/inputmethod.service
index fda02797..366f55d3 100644
--- a/recipes-openharmony/openharmony/files/inputmethod.service
+++ b/recipes-openharmony/openharmony/files/inputmethod.service
@@ -14,6 +14,9 @@ SupplementaryGroups=shell
 CapabilityBoundingSet=CAP_SYS_TIME
 LimitNICE=40
 ExecStart=/usr/bin/sa_main /system/profile/inputmethod_service.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/installs.service b/recipes-openharmony/openharmony/files/installs.service
index a4d7316b..e6508855 100644
--- a/recipes-openharmony/openharmony/files/installs.service
+++ b/recipes-openharmony/openharmony/files/installs.service
@@ -9,6 +9,9 @@ After=hilogd.service
 [Service]
 Type=notify
 ExecStart=/usr/bin/installs
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/media.service b/recipes-openharmony/openharmony/files/media.service
index 837f0cfb..9d3be87f 100644
--- a/recipes-openharmony/openharmony/files/media.service
+++ b/recipes-openharmony/openharmony/files/media.service
@@ -13,6 +13,9 @@ User=system
 Group=media_rw
 SupplementaryGroups=system
 LimitNICE=40
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/mmi-uinput.service b/recipes-openharmony/openharmony/files/mmi-uinput.service
index 2bc61dfb..4c30af79 100644
--- a/recipes-openharmony/openharmony/files/mmi-uinput.service
+++ b/recipes-openharmony/openharmony/files/mmi-uinput.service
@@ -12,6 +12,9 @@ Group=system
 SupplementaryGroups=shell uhid
 LimitNICE=40
 ExecStart=/usr/bin/uinput_inject
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/multimodalinput.service b/recipes-openharmony/openharmony/files/multimodalinput.service
index 2fa19139..e47c7376 100644
--- a/recipes-openharmony/openharmony/files/multimodalinput.service
+++ b/recipes-openharmony/openharmony/files/multimodalinput.service
@@ -12,6 +12,9 @@ Group=system
 SupplementaryGroups=shell uhid
 LimitNICE=40
 ExecStart=/usr/bin/sa_main /system/profile/multimodalinputservice.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/param.service b/recipes-openharmony/openharmony/files/param.service
index 3a9189b9..2e85227a 100644
--- a/recipes-openharmony/openharmony/files/param.service
+++ b/recipes-openharmony/openharmony/files/param.service
@@ -7,6 +7,9 @@ ExecStartPre=install -m 755 -d /run/openharmony/param
 ExecStartPre=install -m 755 -d /data/param
 StandardError=journal
 ExecStart=/usr/bin/param_service
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/samgr.service b/recipes-openharmony/openharmony/files/samgr.service
index f0f26e97..59cd035b 100644
--- a/recipes-openharmony/openharmony/files/samgr.service
+++ b/recipes-openharmony/openharmony/files/samgr.service
@@ -15,6 +15,9 @@ User=system
 Group=system
 ExecStart=/usr/bin/samgr
 LimitNICE=40
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/time.service b/recipes-openharmony/openharmony/files/time.service
index 8e6e64e5..d9421398 100644
--- a/recipes-openharmony/openharmony/files/time.service
+++ b/recipes-openharmony/openharmony/files/time.service
@@ -14,6 +14,9 @@ SupplementaryGroups=shell
 CapabilityBoundingSet=CAP_SYS_TIME CAP_WAKE_ALARM
 LimitNICE=40
 ExecStart=/usr/bin/sa_main /system/profile/time_service.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/tokensync.service b/recipes-openharmony/openharmony/files/tokensync.service
index e9d81f11..eec72503 100644
--- a/recipes-openharmony/openharmony/files/tokensync.service
+++ b/recipes-openharmony/openharmony/files/tokensync.service
@@ -6,6 +6,9 @@ Requires=samgr.service
 Type=exec
 # should run as system:system
 ExecStart=/usr/bin/sa_main /system/profile/token_sync_service.xml
+Restart=on-failure
+StartLimitInterval=300
+StartLimitBurst=5
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/weston.service b/recipes-openharmony/openharmony/files/weston.service
index 43b46adf..4d1df7b4 100644
--- a/recipes-openharmony/openharmony/files/weston.service
+++ b/recipes-openharmony/openharmony/files/weston.service
@@ -15,6 +15,7 @@ Environment="XDG_RUNTIME_DIR=/data/weston"
 Environment="XKB_CONFIG_ROOT=/etc/openharmony/xkb"
 Environment="XKB_CONFIG_EXTRA_PATH=/etc/openharmony/xkb"
 ExecStart=/usr/bin/weston -c /system/etc/weston.ini -B drm-backend.so --tty=1 --use-pixman
+Restart=always
 
 [Install]
 WantedBy=multi-user.target
-- 
GitLab