docs: update procd docs a bit WIP
[web.git] / docs / procd.txt
1 ---
2 ---
3 The Procd System Manager
4 ========================
5
6 == Procd
7
8 _LEDE_ uses 'procd' for booting the system, managing processes and handling parts of the kernel/userland interaction. It can be considered similar to 'systemd' on full blown distributions. Here is a list of tasks that procd will do for us
9
10 === early state and preinit
11
12 Before the real procd runs, a small init process is started. This process has the job of early system init. It will do the following things in the listed order
13
14 * bring up basic mounts such as /proc /sys/{,fs/cgroup} /dev/{,shm,pts}
15 * create some required folder, /tmp/{run,lock,state}
16 * bring up /dev/console and map the processes stdin/out/err to the console (this is the "Console is alive" message)
17 * setup the PATH environment variable
18 * check if "init_debug=" is set int he kernel commandline and apply the debug level if set
19 * initialise the watchdog
20 * start kmodloader and load the modules listed in /etc/modules-boot.d/
21 * start hotplug with the preinit rules (/etc/hotplug-preinit.json)
22 * start preinit scripts found inside /lib/preinit/
23
24 Once preinit is complete the init process is done and will do an exec on the real procd. This will replace init as pid1 with an instance of procd running as the new pid 1. The watchdog file descriptor is not closed. Instead it is handed over to the new procd process. The debug_level will also be handed over to the new procd instance if it was set via commandline or during preinit.
25
26 === procd start up
27
28 Procd will first do some basic process init such as setting itself to be owner of its own process group and setting up signals. We are now ready to bring up the userland in the following order
29
30 * find out if a watchdog file descriptor was passed by the init process and start up the watchdog
31 * setup /dev/console to be our stdin/out/err
32 * start the coldplug process using the full rule set (/etc/hotplug.json) this is done by manually triggering all events that have already happened again using udevtrigger
33 * start ubus, register it as a service and connect to it.
34
35 The basic system bringup is now complete, procd is up and running and can start handling daemons and services
36
37 === /etc/inittab
38
39 Procd supports four commands inside inittab
40
41 * respawn - this works just like you expect it. It starts a process and will respawn it once it has completed.
42 * askfirst - this works just like respawn but will print the line "Please press Enter to activate this console." before starting the process
43 * askconsole - this works like askfirst but instead of running on the tty passed as a paramter will look for the tty defined in the kernel commandline using "console="
44 * sysinit - this will trigger procd to run the command given as a parameter only once. This is usually used to trigger execution of /etc/rc.d/
45
46 Once all items inside /etc/inittab are processed, procd enter its normal run mode and will handle messages coming in via ubus. It will stay in this state until a reboot/shutdown is triggered.
47
48 === ubus command interface
49
50 === hotplug
51
52 Hotplug scripts are located inside /etc/hotplug.d and are based on json_script. This is a json based if then else syntax. Procds hotplug service offers the following actions:
53
54 * makedev
55 * rm
56 * exec
57 * button
58 * load-firmware
59
60 === service startup / monitoring
61
62 WIP
63
64 === (configuration-)triggers
65
66 WIP
67
68 === writing init.d scripts
69
70 WIP