No, systemd doesn't support a syntax like Wants=service@%(i-1).service?
.
However, you could write a simple script that writes out 256 similar systemd unit files which contain an explicit dependency chain. Here are some other patterns to consider:
systemd
allows you to set resource control parameters at run time, with syntax like:
systemctl --runtime set-property foobar.service CPUShares=777
So, you could throttle your units during start up to each use less CPU, then once things have calmed down, allow them to use more CPU. This seems harder than need to be, which brings me to the next option...
- In
man systemd.resource-control
, you'll find that there is a StartupCPUShares=
option which is distinct from the CPUShares=
option. I would experiment with throttling CPU with StartupCPUShares=
to see if produces the result you want.
Personally, I used a very low-tech route to solve a problem like this. I started my series of services one at a time, with a "sleep" between service start. This used a little bash scripting instead of system
, but has worked well enough. Thankfully, I don't also have the requirement to bring all the services online absolutely as soon as possible.
The next iteration of the system I will likely design around systemd
and will like try using StartupCPUShares=
myself to see if it's a better way to solve the problem.