feat: Add openrc-async-services

This commit is contained in:
ptrcnull 2021-11-17 22:28:41 +01:00
parent dee0a6e660
commit 5946683c8c

View file

@ -0,0 +1,52 @@
---
title: "OpenRC: Start services after login prompt"
date: 2021-11-17T21:14:15+01:00
draft: false
---
I'm using Alpine Linux as my main OS on desktop.
As I don't use any display manager/greeter such as LightDM's,
I noticed that it takes quite a bit of time to actually get the login prompt.
After a while of searching through logs,
I realized that some services - primarily `chronyd` - wait
a few seconds for e.g. getting a response from NTP server
and don't exit the start function immediately after starting the process.
I tried googling for a solution and found [this](https://unix.stackexchange.com/a/579014)
Unix StackExchange answer, yet it didn't solve my problem.
_But_, after reading Alpine User Handbook's page on
[OpenRC](https://docs.alpinelinux.org/user-handbook/0.1a/Working/openrc.html),
I got the idea that it could be solved with a bit of tinkering with custom runlevels.
So, the final solution was:
- create a custom runlevel (I chose the name "async", but it doesn't matter)
```bash
sudo mkdir /etc/runlevels/async
```
- add `default` as a [stacked runlevel](https://wiki.gentoo.org/wiki/OpenRC/Stacked_runlevel)
```bash
sudo rc-update add -s default async
```
- remove services from `default` and add them to `async`
```bash
sudo rc-update del chronyd
sudo rc-update add chronyd async
```
- add changing runlevel to `async` to `inittab`
Add this line to `/etc/inittab`:
```
::once:/sbin/openrc async
```
After rebooting, services from `default` runlevel will still block agetty
from running (after all, it has the `wait` label in inittab), but services
from `async` will start separately.