0

I've been searching around for an hour or two but cannot seem to find the correct solution. Here's the situation:

I have multiple services. I start up Service A, which runs a docker container. That application starts up and then writes a file isActive to a mounted directory in the file-system.

I have a Service and Path unit file B. watch.path waits until the isActive exists, which runs watch.service and that service file just echo's out "isActive exists!".

This portion of the logic works fine. I use sudo journalctl -xefb and I watch Service A start up, finish it's registration and then write a file. I then can see that the Service B unit files start, echo out, and finish.

I then have multiple other service files (Service C/D/E/F) that Require and After the Service B watching service. However, Services C/D/E/F are starting way before Service B starts/finishes.

Here is my current 'watching` service:

# watch_for_client.path
[Unit]
Wants=A.service
After=A.service

[Path]
PathExists=/A/B/C/d.txt

[Install]
WantedBy=multi-user.target

# watch_for_client.service
[Unit]
After=A.service

[Service]
Type=oneshot
ExecStart=/bin/echo "file found"

And then in the other files, I have

[Unit]
Requires=wait_for_client.service
After=wait_for_client.service

[Service]
...
Type=simple
...

[Install]
WantedBy=multi-user.target
0

You need to change three things in the service unit file configuration for Services C/D/E/F:

  1. in [Unit] section: erase the line with Requires=wait_for_client.service
  2. in [Unit] section: incorrect name in After=wait_for_client.service
    it should be After=watch_for_client.service to match service B name
  3. in {Install] section: should be WantedBy=watch_for_client.service
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.