Isn’t that what the following line does in the service file?

After=network-online.target
Wants=network-online.target