Retrying scripts? #309
Replies: 2 comments
-
Hi. Your device nodes (such as In dinit we have a feature called triggered-services. These services will not be started until a external trigger occurs. I think you can implement a service that be triggered when udevd (you should have it because of systemd) finds your usb. look at this example: $ cat usb-device-trigger
# This service will be "STARTED" when udevd finds required usb for NAS
type = triggered
$ cat run-mount-usb
type = scripted
command = /bin/mount /dev/sda1 /tmp/usb/sda/sda1
working-dir = /home/root
depends-on = usb-device-trigger Now you should write a "udev rule", This article looks useful for writing them: https://www.baeldung.com/linux/shell-run-script-usb-plugged (You just need to run See https://github.com/davmac314/dinit/wiki/DINIT-SERVICE(5)-man-page#SERVICE_TYPES for more info about triggered services (or |
Beta Was this translation helpful? Give feedback.
-
I agree with Mobin - the best approach is not to have the services fail and then restart them, it is to make sure they start properly. You can use a triggered service along with a udev rule to ensure the device is ready. I note however that from the |
Beta Was this translation helpful? Give feedback.
-
Hello there!
So I was logged into my TV today because I wanted to check my kernel version due to the recent exploits going around, especially this week, and find out just which one it ran, out of curiosity, if it could be helpful in jailbreaking others of the same firmware version or alike. But, while I was there, I looked at my dinit, and I saw this:
This was as expected; mounting the USB drive did not work as intended, possibly because of a timing from when in the init chain the dinit service starts (WebOS inits with systemd first but launches Luna, which launches other services, of which one is the Homebrew Launcher, which in return does a
run-parts
on a directory of which one is mydinit
"service"). So chances are, sometimes, when dinit starts, the mounting script might fail because it runs too early.For reference, here are the units:
Syncthing and the rclone FTP server rely on the USB stick being recognized, so naturally they failed to start - no surprises there. The NAS didn't mount because I forgot to change the IP, oops.
Now, when this mis-timing happens, all it would take is to just re-run the chain from the start again, so that Syncthing and rclone can launch.
What would be the best way to implement a "retry" here?
Kind regards,
Ingwie
PS.: That super long watch-command was an absolute brainfart but the best I could come up with to monitor if it was still mounted or not - and if not, cause the dependees to exit too, if they hadn't already.
Beta Was this translation helpful? Give feedback.
All reactions