Daemons in Gentoo Prefix with OpenRC
Table of Contents
1 Abstract
I am going to take the development of prefix support in OpenRC, deploy OpenRC to work with baselayout in Prefix, and extend Prefix with the long-waited feature1 of services daemons.
2 Objective
Port OpenRC to Gentoo Prefix to organize daemons.
3 Big Picture
Gentoo Prefix is a Gentoo portage managed system installed in a prefix directory. The main purpose is to leverage the Gentoo Linux Portage tree to other Linux distributions, BSD variants, Solaris, hpux, aix and even WINNT.
Gentoo Prefix is usually used by a normal user on the system, providing a systematic way to install new package into a shared computing environment without superuser privilege.
After several years of development since 2006, Gentoo Prefix has grown mature, especially on most tested platforms like x86-linux, amd64-linux, x86-macosx, to name a few.
At present, developers are actively porting changes in Gentoo Prefix back into the main Gentoo Portage tree (in Gentoo community called gentoo-x86), thanks to the introduction of new portage API, aka. "EAPI", 3 and 42.
4 Motive
Gentoo Prefix (hereafter Prefix) is a productive foreground environment. Daemons in Prefix can be run manually to be detached from foreground. This practice is not scalable, and soon becomes tedious.
There was effort to address this issue since 2007 to have services in Prefix, documented in the (in)famous bug #1962941. The scheme works for linux Prefix, but non portable to other host OS like Solaris.
At the same time, Gentoo/*BSD grows and calls for a portable init system that can be used across Linux and BSD kernel/userland. In 2010, OpenRC project answered the call to design a platform-agnostic init system3. Now it matures and serves as default in Gentoo.
Early effort of OpenRC includes a goal of supporting Prefix. But due to lack of man power and the habit of using Prefix only foreground, the Prefix plan was dropped in OpenRC git tree4.
At the same time, Prefix tree becomes an overlay on gentoo-x86, bringing Prefix closer (if not indistinguishable) to standard Gentoo5. It's time to reconsider background support in Prefix with in the light of OpenRC.
5 Deliverables
5.1 general guideline
This project includes exploring experimental features of openrc. Unexpected pieces would emerge along the way.
I will make flexible so I have a number of target to reach within this project and see which will fit or not the timespan.
The first one will be make a good checklist of features openrc has now and which features you want to add to it.
The second one is to compare with other init systems features list and see what we got and what we do not.
The third one is to implement that.
I'd make weekly milestones to see what had been done, what is missing and what to do next, the first one being openrc on prefix.
The end result target will be having the ability to use rc/rc-status and such on a prefix, and at least 3 other main features.
Besides, a rough timeline of my current expectation is created as followed.
5.2 before mid-term
- functioning OpenRC tarball and ebuild on Prefix with superuser privilege (hereafter superuser Prefix)
- improved baselayout ebuild using OpenRC on superuser Prefix
- functioning OpenRC tarball and ebuild on normal user Prefix, which is configurable to be used in superuser Prefix
- baselayout changes reviewed by Gentoo Base Project and merged back into gentoo-x86
- a reference arm-linux Prefix system running mldonkey6, proftpd7, tinc8, nginx9 from OpenRC for demonstration and community use.
- Gentoo documentation or function inside ebuild to guide end user to deploy OpenRC.
5.2.1 Timeline (dates as deadlines) to achieve that
- Investigate the difference between baselayout-{2,prefix}
- Join Gentoo OpenRC herd and get familiar with the source tree.
- Make a git branch out of OpenRC main and develop with it
- Make it run with a directory prefix.
- Make necessary changes to test cases where OpenRC is invoked by host rc system, manual invoking, or cron.
- Introduce a mechanism to separate host rc only tasks from Prefix OpenRC, e.g. kernel module.
- Patch baselayout-prefix to integrate OpenRC prefix branch.
- Reuse the mechanism to separate (or modify) super user only tasks from Prefix OpenRC, e.g. tuning kernel runtime parameters, binding TCP port less than 1024.
If the porting OpenRC is done in a direction of making baselayout-prefix with baselayout-2 more similar, they can be merge into a Prefix-aware baselayout-2.
merge baselayout-prefix with baselayout-2. This
is a by-product, in fact including OpenRC into Prefix requires
modification of baselayout-prefix.
- Use new baselayout and openrc ebuilds to build the demo system, provide access accounts for those who are interested. Document the build procedure as tutorial. If the deploying process needs manual tuning, compose Gentoo documentation to explain the details.
5.3 final
an extra sub project for investigating and evaluating the advertised cool features of systemd, launchd and upstart. Integrate the modern feature as extensions of openrc.
- a report of evaluation on launchd, systemd and upstart from a gentoo point of view
- (optional) A mechanism by which init scripts can configure OpenRC to detect runtime failures, log them and respond to them. The key response we want to enable is to give regular init scripts respawn functionality like we have in /etc/inittab
- (optional) Oom-killer protection via /proc/*/oomadj
- (optional) The ability to perform some sort of maintenance action on a timer (e.g. restart)
5.3.1 Timeline (dates as deadlines) to achieve that
- 10; for systemd: Fedora 15, Mandriva 2011, synchronize with systemd subproject of Gentoo Base Project; for upstart: Ubuntu; for Service Management Facility: Illumos. install reference and develop systems for launchd: MacOSX and FreeBSD
- compare systems against openrc and sysvinit. Find what's missing and what's valuable to be implemented. Figure out a schedule to make balance of time limit and valuable features.
- Carry out the schedule and report the new features to Gentoo community, the majority of openrc user.
6 Biography
I am born in China and now studying in particle physics in Japan as a graduate student. I like tweaking electronic devices and computer programs. Right now I am really fond of travelling around the world and learning different languages.
As a GNU/Linux user for 8 years since 2003, I use Debian for desktop and Gentoo Prefix for servers. I live in Emacs and stumpwm. I started to love Gentoo Prefix in 2010 and joined gentoo four months ago 11.
6.1 experiences
2005 | translated Debian Sarge Release Note into Simplified Chinese12 |
2007–2009 | system administrator for student associations and dormitory in Tsinghua University, China |
2009 | intern in Lava Inc at Beijing, video streaming |
2011 | short intern at Intel China |
2011–now | Consultant for Tsinghua University student group of campus network administrators |
6.2 toys at hand
- mips architecture
- arm architecture
- Buffalo LS-VL running stock system with Gentoo Prefix
- powerpc architecture
- Xilinx Virtex II PRO evaluation board, minimal Debian14
- SONY PlayStation 3, jailbroken, planning to deploy Gentoo
- microblaze architecture
- Xilinx Spartan 3 Starter Kit, minimal busybox
6.3 activities involved in Gentoo
I will just give a few links to my activities
- my reported bugs: http://goo.gl/cv8My
- posts on gentoo-alt: http://goo.gl/WwIXF
Footnotes:
1 https://bugs.gentoo.org/showbug.cgi?id=196294
2 http://devmanual.gentoo.org/ebuild-writing/eapi/index.html
3 http://www.gentoo.org/proj/en/base/openrc
4 http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=3247184d
5 http://archives.gentoo.org/gentoo-alt/msg1f99db167948b65af5c77f55a0a3d093.xml
6 http://packages.gentoo.org/package/net-p2p/mldonkey
7 http://packages.gentoo.org/package/net-ftp/proftpd
8 http://packages.gentoo.org/package/net-misc/tinc
9 http://packages.gentoo.org/package/www-servers/nginx
10 http://wiki.freebsd.org/launchd
11 http://archives.gentoo.org/gentoo-project/msgc752a3d5119130dd715ebc587536e00c.xml
12 http://www.debian.org/releases/sarge/releasenotes
14 http://www.awa.tohoku.ac.jp/~benda/projects/virtex2p.html