How to run a service after another service

I have two services, say serviceA in serviceA.rc & serviceB in serviceB.rc running on my AOSP Hikey960.

My serviceB depends on serviceA. How can I set the order of service execution so that serviceB is started after serviceA ? Do I have to use setprop ? Or use restart/start/disabled in on of my services ?

Is there any particular order in which the services are executed ?

If you are using systemd, then you can specify the service dependency in unit file as explained below:

I am using Android init system. Not sure if its systemd :sweat_smile:

Definitely NOT systemd. Android’s init is pretty primitive.

I’m not sure if there is an order in which they are executed, BUT, I can tell you that init is parallel, so even if they do start generally in some order, you can’t count on the first one being in a ready state before the second one needs it.

You pretty much have to use the service disabled, on property a=b enable and start approach to guarantee that it does what you need it to do.

HOWEVER, there is probably another way to do what you’re trying to do.
For example, combine the two services into a single binary, and do a fork/exec within it, or, since one of your two services depends on the other, why not perform a startup synchronization within the dependent? As a really simple example, while (otherserviceisnotavailable()) sleep(1);