0

I have 2 systemd services.

a.service b.service

b depends on a but I don't want to explicitly mention the dependency in b.service file. Instead I am waiting on the org.freedesktop.DBus.Properties.PropertiesChanged signal from a.service when it starts at boot-up in the code of b.c and poll until I get that signal for it to become active.

           sd_ret = sd_bus_match_signal
                    (
                       bus,
                       NULL,
                       DESTINATION,         
                       A_PATH,           
                       INTERFACE,           
                       "PropertiesChanged", 
                       sd_callback,         
                       NULL                 
                    );

And then use poll to wait on signal from dbusfd.

I did the following experiment:

Experiment 1:

STEP 1:

systemctl mask a.service

systemctl mask b.service

STEP 2: reboot

STEP 3:

systemctl unmask a.service

systemctl unmask b.service

STEP 4: run the 'b' binary

./b

STEP 4:

systemctl start a.service

Observation:

b.service is able to catch the signal:

Signal match triggered! destination=(null) interface=org.freedesktop.DBus.Properties member=PropertiesChanged path=/org/freedesktop/systemd1/unit/a2eservice
Starting to poll
Signal match triggered! destination=(null) interface=org.freedesktop.DBus.Properties member=PropertiesChanged path=/org/freedesktop/systemd1/unit/a_2eservice
Property name: ActiveState
Updated ActiveState: active
a Service is now active.

But in Experiment 2

Both service unmasked during boot-up.

At boot-up the a.service does not seem to emit the PropertiesChanged signal.

So wanted to know if the behavior of a service is same during boot-up and after boot-up and does a service send PropertiesChanged signal during boot-up ?

2
  • How do you know that the signal wasn't emitted before your listener (b.service) started? Commented Jan 3 at 7:46
  • From the journal logs I can see that the b.service starts first and sees the a.service is not in active state using the sd_bus_call_method(.."Get"..) and then b.service goes into poll blocking call indefinitely. After that in the log I see the a.service is invoked and is ready. But the b.service never comes out of poll() Commented Jan 3 at 15:19

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.