I have a question regarding making my own unit (service) file for Systemd.
I've read the documentation and had some questions. After searching around, I found this very helpful answer that gives some detail about some of the questions I was having.
Although I find that answer useful, there is still one part that I do not understand. Mainly this part:
Since we actually want this service to run later rather than sooner, we then specify an "After" clause. This does not actually need to be the same as the WantedBy target (it usually isn't)
My understanding of After is that it is pretty straight forward. The service (or whatever you are defining) will run after the unit listed in After.
Similarly, WantedBy seems pretty straight forward. You are defining that the unit you list has a Want to your service. So for a target like multi-user or graphical, your unit should be run in order for systemd to consider that target reached.
Now, assuming my understanding of how these declarations work is correct so far, my question is this: Why would it even work to list the same unit in the After and WantedBy clauses?
For example, defining a unit that is After multi-user.target and also WantedBy multi-user.target seems to me like it would lead to an impossible situation where the unit needs to be started after the target is reached, but also it needs to be started for the target to be considered "reached".
Am I misunderstanding something?