Baptiste Daroussin, a member of the FreeBSD Core Team and the author of the pkg package manager, is developing a new system manager for FreeBSD — rcd. The rcd system manager is invoked by the init process instead of /etc/rc; it reads the configuration files of services (/etc/rcd.d/*.ucl), builds a dependency tree, and starts the services in parallel whenever possible. Afterward, it monitors the operation of the services and restarts them if necessary.
Background process management and operations with services can be performed via direct command transmission to a UNIX socket or with the help of the command-line utility rctl. Unit files with service parameters are designed in UCL format, which resembles the configuration file format of nginx and bind, incorporating elements for simplified automated processing borrowed from JSON. There is an option to create templates for typical unit files and write embedded handlers in Lua. An example unit file to start nginx: name = "nginx"; description = "Nginx HTTP Server"; type = "simple"; command = "/usr/local/sbin/nginx"; command_args = "-g 'daemon off;'"; provides = ["nginx", "http"]; requires = ["NETWORKING", "sshd"]; restart { policy = "always"; max_retries = 10; delay = 2000; backoff = "linear"; } process { user = "www"; group = "www"; cpuset = "0-3"; } rctl { memoryuse = { action = "deny"; amount = "2g"; }; pcpu = { action = "throttle"; amount = "80"; }; }
Instead of working with PID files, the tracking of active running processes is done using the descriptors returned by the system call pdfork(). There is support for activating services only when accessing the network socket, and the ability to protect important services from forced termination in cases of memory shortage in the system. It is possible to update the version of the background process rcd on the fly without losing state.
To limit the resources available to the service, rctl is used, and for complete isolation of services, their launch in jail environments is supported. Access to the controlling UNIX socket can be configured in relation to specific services. Sleep mode transition is supported.
A rendszerkezelő teljes mértékben visszafelé kompatibilis a meglévő rc.d szolgáltatások sorozatos indítási rendszerével, és képes működni a meglévő rc.d-scriptek és konfigurációs fájlok módosítása nélkül. Elég telepíteni az rcd-t egy működő rendszerre, és a következő újraindítás után minden úgy fog működni, mint korábban, azzal a kivétellel, hogy a szolgáltatások indításának párhuzamosításával csökken a betöltési idő. Ez a kompatibilitás megkönnyíti a rendszerek rcd-re való migrálását, és lehetővé teszi a meglévő rc.d-scriptek fokozatos átkonvertálását unit-fájlokká.
Az rc.d kompatibilitásához speciális «legacy» unit típus támogatott. Az rcd beolvassa a /etc/rc.d/ és /usr/local/etc/rc.d/ tartalmát, elemzi a PROVIDE/REQUIRE/BEFORE/KEYWORD címkéket a scriptekben, olvassa az rc.conf beállításait és meghatározza a scriptek indítási állapotát, majd minden scriptet virtuális legacy unitként kezel. Ha a rcctl parancsot használják az ilyen virtuális unitok kezelésére, a műveletek visszafelé transzformálva vannak az ősi formátumban, például az „rcctl reload sshd” végrehajtása a „/etc/rc.d/sshd reload” indításhoz vezet.
Forrás: opennet.ru
