Outils pour utilisateurs

Outils du site


blog

Notes dinit

Présentation

type = process | bgprocess | scripted | internal | triggered
command = ...
stop-command = ...
run-as = (user-id)
restart = (boolean)
logfile = ...
pid-file = ... (Pour bgprocess)
options: ...
depends-on: (service name) (Hard dependency / Need dependency)
depends-ms: (service name) (Milestone)
waits-for: (service name) (Soft dependency)

Install

Debian

Voir : https://repo.antixlinux.com/testing/pool/main/d/dinit/

wget https://repo.antixlinux.com/testing/pool/main/d/dinit/dinit_0.19.4-0_amd64.deb
mkdir dinit_tmp
cd dinit_tmp
ar x ../dinit_0.19.4-0_amd64.deb
tar xvf data.tar.xz
sudo cp -p lib/dinit/dinit* /usr/local/bin/
sudo rsync -ax usr/share/man/ /usr/local/share/man/
Android - Termux

Source : https://github.com/davmac314/dinit/issues/274

pkg install ndk-sysroot clang binutils-is-llvm make git
pkg install m4
git clone https://github.com/davmac314/dinit
cd dinit
 
git tag
git checkout v0.19.4
 
./configure --prefix=$PREFIX --syscontrolsocket=$PREFIX/var/run/dinitctl --sbindir=$PREFIX/bin --disable-cgroups --disable-shutdown
make -j $(nproc)
make install
Termnux boot

Installer Termux-Boot

cd .termux
mkdir boot
cd boot
 
cat > 00-dinit <<EOF
#! /bin/sh
 
termux-wake-lock
dinit
EOF
 
termux-fix-shebang ./00-dinit

Usage

$ dinit --version
Dinit version 0.19.4.
Supported features: cgroups utmp supplemental-groups
mkdir ~/.config/dinit.d
cd ~/.config/dinit.d
 
cat > ~/.config/dinit.d/boot <<EOF
type = internal
waits-for.d: boot.d
EOF
 
mkdir /.config/dinit.d/boot.d
Exemple de création de service

Voir :

cat > ~/.config/dinit.d/test_sleep <<EOF
type = process
command = sleep 600
restart = true
EOF
 
dinit
 
dinitctl start test_sleep

État

dinitctl list
 
dinitctl status mysql

Vérif

dinitcheck
 
# ou
 
dinitcheck <service-name>

Config

Lancement automatique de dinit

~/.bashrc

if ! pgrep -u "$USER" dinit > /dev/null; then
  nohup dinit --user -q -l ~/log/dinit.log >/dev/null 2>&1 &
fi

Source : Adaptation de https://wiki.artixlinux.org/Main/Dinit#User_services

Pb

oct 17 17:44:45 vivabelo systemd[2332]: nerdctl-3249c67de5a1a127575835e672573bd05d1fd478bca842293869a7bc2a0a1539.scope: Consumed 2min 37.055s CPU time, 2.1G memory peak, 430M read from disk, 82.7M written to disk.
oct 17 17:44:45 vivabelo containerd-rootless.sh[2454]: time="2025-10-17T17:44:45.171069378+02:00" level=error msg="ttrpc: received message on inactive stream" stream=9

Pb

Err provided file is not a console
Exited (137)
1 errors:\nprovided file is not a console

Solution

apt-get install expect

~/.config/dinit.d/kind

type = process
 
# command = $HOME/bin/nerdctl start --attach kind-control-plane
command = unbuffer $HOME/bin/nerdctl start --attach kind-control-plane
 
stop-command = $HOME/bin/nerdctl stop kind-control-plane
restart = false
logfile = /home/jibe/log/kind.log
stop-timeout = 120

Préfixer la commande par unbuffer

Mais ne marche pas :

  • stdbuf -i0 -o0 -e0 command
  • script --return --quiet --command “rancher exec -ti …” /dev/null
2025/10/11 21:11 · Jean-Baptiste

Notes Ansible EDA - Event-Driven Ansible - ansible-rulebook

Voir :

Ou comment réinventer le FAAS

FIXME

2025/10/09 22:01 · Jean-Baptiste

Notes PID1 conteneurs

Généralités

Voir ;

Voir aussi :

Design - supervision system vs service manager vs system manager - “hard” and “soft” dependencies.

Init process :

Init process pour les conteners :

L'entrypoint devrait être un init tel que “catatonit”

Something like dumb-init or tini can be used if you have a process that spawns new processes and you don't have good signal handlers implemented to catch child signals and stop your child if your process should be stopped etc.

If your process doesn't spawn new processes (e.g. Node.js), then this may not be necessary.

I guess that MongoDB, PostgreSQL, ... which may run child processes have good signal handlers implemented. Otherwise there would have been zombie processes and someone would have filed an issue to fix this.

Only problem may be the official language images, like node, ruby, golang. They don't have dumb-init/tini in it as you normally don't need them. But it's up to the developer which may implement bad child execution code to either fix the signal handlers or use helper as PID 1.

Source : https://stackoverflow.com/questions/37374310/how-critical-is-dumb-init-for-docker

Sans gestion de services

Voir :

Voir :

  • tini
  • dumb-init
  • catatonit (recommandé), utilisé par Podman - inspiré de tini et de dumb-init
  • pid1 (paquet pid1) https://github.com/fpco/pid1

Avec gestion de services

Voir :

Pas classé

Voir :

2025/10/09 21:46 · Jean-Baptiste
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki