Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
JanZachmann committed Apr 25, 2024
1 parent 37fae3f commit 32ea784
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/twin/web_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ impl WebService {
An example for a complete generic handling can be found in iot-identity-service code:
https://github.com/Azure/iot-identity-service/blob/main/http-common/src/connector.rs
The socket is not reliable removed by systemd when the service stops, crashes or return with an error.
As a result sometimes files or directories with wrong permissions are created. Thus we to cleanup in
systemd "ExecStartPre" and "ExecStopPost".
The socket is not reliable removed by systemd when the service stops, crashes or returns with an error.
As a result sometimes files or directories with wrong permissions are created. Thus we cleanup socket in
omnect-device-service.socket "ExecStartPre" and "ExecStopPost".
*/
const SOCKET_FDS_IDX: std::os::unix::io::RawFd = 3;

Expand Down
3 changes: 0 additions & 3 deletions systemd/omnect-device-service.exec_stop_post.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash -x
script=${0}
socket_file="/run/omnect-device-service/api.sock"
update_validation_file="/run/omnect-device-service/omnect_validate_update"
barrier_json="/run/omnect-device-service/omnect_validate_update_complete_barrier"
max_restart_count=9
Expand All @@ -13,8 +12,6 @@ function reboot() {
dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.Reboot" boolean:true
}

rm -rf ${socket_file}

# for now we ignore SERVICE_RESULT and EXIT_STATUS. however it does potentially
# make sense to reboot on certain combinations even if restart_count < max_restart_count
# or update validation is not yet timeouted. (we have to gain experience.)
Expand Down
1 change: 0 additions & 1 deletion systemd/omnect-device-service.service
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Group=omnect_device_service
WatchdogSec=30s

ExecStart=/usr/bin/omnect-device-service
ExecStartPre=/usr/bin/omnect-device-service.exec_start_pre.sh
ExecStopPost=/usr/bin/omnect-device-service.exec_stop_post.sh

[Install]
Expand Down
3 changes: 3 additions & 0 deletions systemd/omnect-device-service.socket
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ SocketMode=0660
SocketUser=omnect_device_service
SocketGroup=omnect_device_socket

ExecStartPre=+rm -rf /run/omnect-device-service/api.sock
ExecStopPost=+rm -rf /run/omnect-device-service/api.sock

[Install]
WantedBy=sockets.target

0 comments on commit 32ea784

Please sign in to comment.