Restarting modep-mod-ui from ascript: Need a sleep!

Friends

I am making great progress on my real-time pedal.

As a part of my project I would like to stop my software and restart modep-mod-ui from a script

Doing it from the command line I found I had to stop modep-mod-host first, odd, because it is not running. I have no explanation for that.

Once I stop modep-mod-host I need to sleep for a second before I start modep-mod-ui. That really grates. I hate using sleep to fix a bug.

There must be some process ocuring that that I could test rather than sleep. Frustrating

This is the code rather obvious except for killing the copy of mod-host I use for my pedal (my hacked version) and killing pd that I use to adjust the volume of the output

After stopping

I assume your modep-mod-ui and modep-mod-host are system services. If it’s like MOD, then modep-mod-ui specifies modep-mod-host as a dependent service.

So you should be able to just execute:
sudo systemctl stop modep-mod-host modep-mod-ui

systemctl stages the stops and starts to avoid race conditions.