-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Start new systemd services explicitly? #23221
Comments
In my opinion it would be preferable if we could delegate that logic to systemd, so ideally |
Yeah, it seems like all instances of |
Staring at this, I'm growing more convinced to do what @fpletz says and replace all the The main downside I can see is that we lose the Any objections? Edit: I guess we'd also need to keep some |
Should we really start |
I guess we should start whichever target systemd wants to start by default. I think it chooses |
@copumpkin well but you can switch to a different target after boot, by doing things like |
Yeah, not really sure. I'm just going to push up the current code as a PR and get some feedback. |
…lves Instead we use default.target, which mostly has the same behavior, but allows us to start up new services during boot, as needed by amazon-init (and presumably cloud-init if people used it much for NixOS). See here for more info: NixOS#23221
Maybe I don't understand the problem correctly, but if the issue is that the reconfiguration service runs before BTW, it might be interesting to look into |
@edolstra well, in part it feels like a "flash of unstyled content" issue like the bad ol' days of web programming: in an ideal world, I'd have an EC2 API that looked like It seems like calling I'll take a look at |
I guess using |
@copumpkin could you perhaps just boot to |
Yeah, perhaps. Although I'm a little concerned because all the stuff about |
The folks in #systemd are steering me away from |
Somewhat moot now given 6018cf4, but I'm still going to try to improve that process. |
Currently, new services added by a new NixOS configuration only get started implicitly by
switch-to-configuration
when targets wanting or requiring them get started. For example, in #23121,httpd.service
iswantedBy
multi-user.target
, so it only gets started when we callsystemctl start multi-user.target
The issue arises when we want to add new services during startup, as we do with the EC2 userdata reconfiguration machinery. We currently only do this for EC2, but in #22105 I suggest we should generalize it, as more and more hosting/cloud providers (GCE, Packet.net, DigitalOcean, etc.) have similar functionality. It's a nice piece of functionality, since it lets you configure machines declaratively without needing to speak to them directly (e.g., in EC2 autoscaling groups, secure setups where the machine configuring boxes doesn't necessarily have access to the network the boxes go into, etc.).
When adding units at startup, the target that wants a given service might not be active yet. In #23121, we don't start
multi-user.target
because it hasn't been activated yet, and we probably shouldn't start it that early in the boot process.I'm not sure how best to solve this. We could make
switch-to-configuration.pl
explicitly enumerate new services added in a new configuration and callsystemctl start --no-block
on it (as suggested in this blog post), or we could possibly get the pre-existing targets (which are still starting up) to somehow trigger new services that want them. I don't know how to tellsystemd
to do that though...Or maybe it makes sense to call
systemctl start --noblock default.target
on every invocation ofswitch-to-configuration.pl
?cc @edolstra @wkennington @shlevy
The text was updated successfully, but these errors were encountered: