[systemd-devel] Generators, Targets and Stater Units - I am holding it wrong?
Andrei Borzenkov
arvidjaar at gmail.com
Mon Jun 23 06:16:58 UTC 2025
22.06.2025 23:30, Marc Haber wrote:
> Hi,
>
> the following works, but I doubt that it is a nice way to do it. I have
> a generator that generates a number of service, and I want all of those
> services automatically started at boot. I have:
>
> $ sudo systemctl cat console-log-8.service
> [sudo] password for mh on hover:
> # /run/systemd/generator/console-log-8.service
> # generated by console-log.generator
>
> [Unit]
> Description=page tty8
> After=console-log.target
>
> [Service]
> ...
>
> [Install]
> WantedBy=console-log.target
> $ sudo systemctl cat console-log-9.service
> # /run/systemd/generator/console-log-9.service
> # generated by console-log.generator
>
> [Unit]
> Description=page tty9
> After=console-log.target
>
> [Service]
> ...
>
> [Install]
> WantedBy=console-log.target
> $ sudo systemctl cat console-log.target
> # /run/systemd/generator/console-log.target
> # generated by console-log.generator
>
> [Unit]
> Description=Pull in all console-log units
> After=multi-user.target
> Wants=console-log-9-var-log-syslog-syslog.service
> Wants=console-log-8-var-log-exim4-mainlog.service
>
> [Install]
> WantedBy=multi-user.target
> $ sudo systemctl cat console-log-starter.service
> # /etc/systemd/system/console-log-starter.service
> [Unit]
> Description=Start console-log.target at boot
> After=multi-user.target
>
> [Service]
> Type=oneshot
> ExecStart=/bin/systemctl start console-log.target
> RemainAfterExit=yes
>
> [Install]
> WantedBy=multi-user.target
>
> $
>
> The console-log-starter.service is the only persistent thing, all others
> are generated (including the target since the target lists all generated
> services). So I cannot enable them. The console-log-starter.service is
> the first unit that I can actually enable.
>
> When I search on the Internet I read that the generator should generate
> "the Wanted" Symlinks itself, but the docs also say that the generator
> can't write outside its target directories. And I don't have a clue
> which symlinks I am supposed to generate in the generator.
/run/systemd/generator/console-log-starter.service.wants/console-log-9.service
-> /run/systemd/generator/console-log-9.service
More information about the systemd-devel
mailing list