COMPARISON 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. Comparison of Dinit with other supervision / init systems
  2. =========================================================
  3. This is intended to be an objective description of the differences between
  4. Dinit and several other similar software packages. Due to a myriad of details,
  5. it is difficult to provide a very meaningful comparison without going into
  6. great detail (which this document does not). It does, however, serve as a
  7. short survey of service supervision and init systems, and provides a starting
  8. point for understanding the unique features of Dinit.
  9. Systems without dependency management
  10. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  11. A variety of init/supervision packages do not perform proper dependency management
  12. of supervisions. By this I mean that, broadly speaking:
  13. - starting a service should automatically start any services that the former
  14. requires (and wait, if appropriate, until they have started)
  15. - likewise, stopping a service should automatically stop any dependent services.
  16. Dinit (and various other packages) perform dependency management. The following
  17. packages do not:
  18. * Daemontools (http://cr.yp.to/daemontools.html)
  19. * Epoch (http://universe2.us/epoch.html)
  20. * Finit (http://github.com/troglobit/finit)
  21. * Minit (http://www.fefe.de/minit)
  22. * Perp (http://b0llix.net/perp/)
  23. * Runit (http://smarden.org/runit/)
  24. I've read arguments that suggest dependency management isn't really needed: if a
  25. service really does require another, then it fail in some way when the dependency
  26. goes down, and should then go down itself; supervision of the service may try to
  27. restart it, but should use an increasing delay to avoid continuously bouncing the
  28. service up and down. In my opinion this could create unnecessary load, unnecessary
  29. delay, and noise in logs that might make it more difficult to pinpoint the cause
  30. of problems, though I'll acknowledge that in simpler setups these are unlikely to
  31. be real problems.
  32. Not all services will necessarily behave as is required for this type of service
  33. management to work properly. An argument could be made that this is a fault of the
  34. particular service / daemon, but practical considerations may be in play.
  35. The basic problem of starting login sessions only after system initialisation has
  36. (at least partially) completed is naturally solved with a dependency-managing
  37. solution; you can have the tty sessions (getty) depend on some other service unit
  38. which, in turn, depends on the basic system initialisation services. In non-
  39. dependency-handling managers this must usually be special-cased (eg an "inittab"
  40. which is processed once all services have started).
  41. With all the above in mind, I feel that dependency management allows generally
  42. greater flexibility and control in how services are managed. While this might not
  43. always be useful, and comes at a certain cost of complexity, I argue that it is at
  44. least sometimes useful, and that the cost is not so high. However, to be fair,
  45. many systems have successfully taken the simpler approach.
  46. Nosh suite (http://homepage.ntlworld.com/jonathan.deboynepollard/Softwares/nosh.html)
  47. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  48. Another seemingly modular init system offering dependency management and socket
  49. activation, with BSD licensing. Service configuration is expressed through
  50. directory structure (symbolic links represent service dependencies, etc;
  51. "start", "stop" and "run" commands are individual scripts within a service
  52. directory bundle). It provides a simple shell-like scripting language which can be
  53. used (via the "nosh" interpreter) to implement service commands without requiring
  54. the user of a full shell. Several "chain loading" utilities are provided to
  55. allow running processes in a different directory, with a different user id, with
  56. resource limits, etc.
  57. It was originally designed for BSD systems but works on Linux too (i.e. is
  58. portable). It does not provide a D-Bus interface.
  59. Compared to Dinit, the two most significant differences appear to be use of a
  60. directory structure for service configuration (Dinit uses a combination of
  61. directory structure and ini-style configuration file), and use of small chain
  62. loading utilities to implement service parameters (Dinit has a wider range of
  63. direct configuration options via the service description file).
  64. Nosh seems to be a quite mature system with a range of features that makes it
  65. appear competitive, feature-wise, in terms of system/servive management, with
  66. Systemd - though without a lot of the feature-creep extras that can easily be
  67. implemented separately.
  68. OpenRC (Gentoo)
  69. -=-=-=-=-=-=-=-
  70. The OpenRC system used in Gentoo Linux is a dependency-managing service supervision
  71. system with functionality that may similar in some respects to Dinit. According to
  72. Wikipedia, it provides parallel startup of services (like Dinit), though this is
  73. disabled by default. It is designed to be used in conjunction with a primary init
  74. which handles system management and which defers to openrc at boot or shutdown to
  75. bring services up or down.
  76. Unusually, OpenRC does not run as a daemon itself; it terminates once it has
  77. established service states. It has some support for integration with service
  78. supervisors such as S6.
  79. Service configuration is specified via a shell script, with the 'openrc-run'
  80. interpreter (which makes certain special shell functions available, and interprets
  81. shell variables once the service script completes. For performance reasons
  82. metatdata extracted from the service scripts is cached in an alternative format.
  83. Although the build system seems to have some support for BSD OSes, it did not
  84. build successfully on OpenBSD when tested (revision 33d3f33).
  85. S6-RC (http://skarnet.org/software/s6-rc/s6-rc.html)
  86. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  87. S6-RC provides a dependency-management system over the top of the S6 supervision
  88. system. S6-RC requires compiling the complete set of service descriptions into a
  89. database. Services are are configured via a directory structure, with a
  90. one-parameter-per-file style, rather than a single service description file.
  91. As well as services, S6-RC has the concept of service "bundles", named groups
  92. of services that can be started/stopped as a group.
  93. New services cannot be added once the system is in operation, and service
  94. definitions cannot be changed in general, except by re-compiling the database;
  95. S6-RC will then start any new services as required (and stop any processes no longer
  96. considered part of an active service).
  97. S6-RC in general seems to follow the philosophy of breaking up functionality into smaller
  98. parts and implementing these smaller parts as separate programs, wherever
  99. practical. Thus, process supervision, log file management, and service management
  100. are all separate programs.
  101. In contrast to S6-RC, Dinit does not requires compiling service definitions, instead
  102. loading and parsing them on-the-fly. Also, Dinit incorporates service
  103. supervision and management into a single process (and does not require one
  104. supervisory process per service). On the other hand, the Dinit process is
  105. somewhat more complex than any of the individual S6-RC components.
  106. S6-RC nicely manages chaining of service standard input/output, facilitating
  107. setting up a logging chain where a logging process consumes the output of a
  108. service, and either can be restarted while losing only minimal (if any)
  109. output from the logs.
  110. It appears that S6-RC supports only hard dependencies: that is if, a service depends
  111. on another then that service must start, and stay running. Dinit supports a number
  112. of dependency types including "soft" dependencies which allow the dependency to
  113. stop or fail without necessarily stopping the dependent.
  114. Systemd
  115. -=-=-=-
  116. Systemd is probably the most widely used init system on Linux as in recent years.
  117. Compared to Dinit, Systemd provides a range of functionality such as:
  118. - setting priority and various other attributes of the service process that
  119. Dinit does not support [yet].
  120. - seat/session management
  121. - syslogd replacement (or at least, partial replacement)
  122. - ability to run tasks at certain times
  123. - inetd replacement (lazily launch services to handle connection to IP ports)
  124. - asynchronous filesystem check/mount
  125. - control group (cgroup) / container management
  126. - private tmp directories for services / login sessions
  127. - system time management
  128. Some of this functionality can be found in other daemons/packages which can be be used
  129. to supplement the functionality of Dinit or another service manager, and even in the
  130. case of Systemd, some of the functionality is not part of the core process (the
  131. actualy systemd binary).
  132. In Systemd terminology, it manages "units" of which services are one type. In practice
  133. this is an issue only of nomenclature; Dinit "services" and Systemd "units" are, I think,
  134. essentially the same thing.
  135. Systemd running in "system" mode does not properly support running with a PID other than
  136. one [1]. That is, it must replace /sbin/init. Systemd can however be run in "user" mode
  137. where it (most likely) provides roughly the same level of functionality as Dinit, though
  138. in a more complex package.
  139. The Systemd interdependence graph is more complex than for Dinit and most other
  140. dependency-handling service managers: a service can conflict with another service, meaning
  141. that starting one causes the other to stop and vice versa. Systemd implements shutdown
  142. via a special "shutdown" unit which conflicts with other services so that they stop
  143. when the shutdown is "started". Other service managers typically do not implement shutdown
  144. as a service but as a special action; they then don't need to support conflicting
  145. services.
  146. The "shutdown" unit is just one example of a "special" service. Systemd has several such
  147. services, for various purposes, including for tight integration with D-Bus (Systemd
  148. exposes a D-Bus API, and contains its own implementation of the D-Bus protocol).
  149. Systemd makes no attempt to be portable to operating system kernels other than Linux.
  150. The maintainers have stated that they consider it infeasible to port to non-Linux-based
  151. OSes and will refuse patches designed to do so [2]. Dinit, by comparison, strives to be
  152. portable.
  153. [1] http://freedesktop.org/software/systemd/man/systemd.html as at 18/11/2015
  154. [2] http://freedesktop.org/wiki/Software/systemd/InterfacePortabilityAndStabilityChart/
  155. as at 18/11/2015
  156. Cinit (http://www.nico.schottelius.org/software/cinit; defunct)
  157. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  158. An obscure init system which apparently offers portability and dependency
  159. management, just as Dinit does. Development appears to have ceased some
  160. time ago, unfortunately.
  161. InitNG (http://initng.org/trac; defunct)
  162. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  163. A highly modular init system which apparently offers dependency management
  164. (as Dinit does). Portability status is unclear; may be Linux-only (Dinit
  165. strives for portability). Development may have ceased (website is now showing
  166. Japanese text which I am unable to read) although there are what looks like
  167. maintenance commits from 2017 in the Github repository at
  168. https://github.com/initng/initng.
  169. Upstart (Ubuntu; http://upstart.ubuntu.com)
  170. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  171. Upstart does not provide real dependency management; instead "events" (including services
  172. starting or stopping) can be specified to trigger start/stop of other services. This is
  173. backwards from the Dinit approach (and that taken by most dependency-managing supervision
  174. systems) which allow the dependencies of a service to be specified declaratively. That is,
  175. if service A depends on service B, Upstart is configured so as to start B whenever A starts
  176. (and it's not possible, or at least not trival, to start A without also starting B).
  177. Upstart apparently offers a D-Bus interface. Dinit eschews D-Bus in favour of a simple
  178. custom control protocol.