···5858 before the activation script is run. This behavior is different when the
5959 service is socket-activated, as outlined in the following steps.
60606161- - The last thing that is taken into account is whether the unit is a service
6262- and socket-activated. If `X-StopIfChanged` is **not** set, the service
6363- is **restart**ed with the others. If it is set, both the service and the
6464- socket are **stop**ped and the socket is **start**ed, leaving socket
6565- activation to start the service when it's needed.
6161+ - The last thing that is taken into account is whether the unit is a
6262+ service and socket-activated. A correspondence between a
6363+ `.service` and its `.socket` unit is detected automatically, but
6464+ services can **opt out** of that detection by setting
6565+ `X-NotSocketActivated` to `yes` in their `[Service]`
6666+ section. Otherwise, if `X-StopIfChanged` is **not** set, the
6767+ service is **restart**ed with the others. If it is set, both the
6868+ service and the socket are **stop**ped and the socket is
6969+ **start**ed, leaving socket activation to start the service when
7070+ it's needed.
66716772## Sysinit reactivation {#sec-sysinit-reactivation}
6873
···535535 '';
536536 };
537537538538+ notSocketActivated = mkOption {
539539+ type = types.bool;
540540+ default = false;
541541+ description = ''
542542+ If set, a changed unit is never assumed to be
543543+ socket-activated on configuration switch, even if
544544+ it might have associated socket units. Instead, the unit
545545+ will be restarted (or stopped/started) as if it had no
546546+ associated sockets.
547547+ '';
548548+ };
549549+538550 startAt = mkOption {
539551 type = with types; either str (listOf str);
540552 default = [];
···544544 }
545545 }
546546547547+ if (parse_systemd_bool(\%new_unit_info, "Service", "X-NotSocketActivated", 0)) {
548548+ # If the unit explicitly opts out of socket
549549+ # activation, restart it as if it weren't (but do
550550+ # restart its sockets, that's fine):
551551+ $socket_activated = 0;
552552+ }
553553+547554 # If the unit is not socket-activated, record
548555 # that this unit needs to be started below.
549556 # We write this to a file to ensure that the
···6666 # login and store session
6767 machine.log(machine.succeed(f"http --check-status --session=frigate post http://localhost/api/login user=admin password={password}"))
68686969- # make authenticated api requested
6969+ # make authenticated api request
7070 machine.log(machine.succeed("http --check-status --session=frigate get http://localhost/api/version"))
7171+7272+ # make unauthenticated api request
7373+ machine.log(machine.succeed("http --check-status get http://localhost:5000/api/version"))
71747275 # wait for a recording to appear
7376 machine.wait_for_file("/var/cache/frigate/test@*.mp4")
···7474// `stopIfChanged = true` is ignored, switch-to-configuration will handle `restartIfChanged =
7575// false` and `reloadIfChanged = true`. This is the same as specifying a restart trigger in the
7676// NixOS module.
7777+// In addition, switch-to-configuration will handle notSocketActivated=true to disable treatment
7878+// of units as "socket-activated" even though they might have any associated sockets.
7779//
7880// The reload file asks this program to reload a unit. This is the same as specifying a reload
7981// trigger in the NixOS module and can be ignored if the unit is restarted in this activation.
···613615 } else {
614616 // If this unit is socket-activated, then stop the socket unit(s) as well, and
615617 // restart the socket(s) instead of the service.
618618+ // We count as "socket-activated" any unit that doesn't declare itself not so
619619+ // via X-NotSocketActivated, that has any associated .socket units.
616620 let mut socket_activated = false;
617621 if unit.ends_with(".service") {
618622 let mut sockets = if let Some(Some(Some(sockets))) = new_unit_info.map(|info| {
···662666 }
663667 }
664668 }
669669+ }
670670+ if parse_systemd_bool(new_unit_info, "Service", "X-NotSocketActivated", false) {
671671+ // If the unit explicitly opts out of socket
672672+ // activation, restart it as if it weren't (but do
673673+ // restart its sockets, that's fine):
674674+ socket_activated = false;
665675 }
666676667677 // If the unit is not socket-activated, record that this unit needs to be started