Systemd

What is Systemd?

What is init system?

  • SysV
  • upstart
  • launchd

Why do we need another init system?

Welcome Systemd

Why should I care?

  • Debian
  • Ubuntu
  • CentOS
  • Fedora
  • Arch
  • CoreOS
  • OpenSUSE
  • Mageia

We use it too

What I have to know?

Design

  • service
  • target
  • timer
  • ...

/etc/systemd/system

/lib/systemd/system

systemctl

systemctl status
systemctl status myapp
systemctl restart myapp
systemctl reload myapp
systemctl start myapp
systemctl stop myapp
systemctl enable myapp
systemctl disable myapp
systemctl --failed

journalctl

journalctl -f # like tail -f
journalctl -u unitname
journalctl -b # since last boot
journalctl -n 100
journalctl --since yesterday
journalctl -o json # different outputs
journalctl -p 3..6 # filtering by priority

Templates

[Unit]
Description=%I Sidekiq Daemon
Documentation=https://github.com/monterail/ansible-sidekiq
StopWhenUnneeded=yes
PartOf=%i.target

[Service]
User=%i
WorkingDirectory=/home/%i/app/current
ExecStart=/bin/bash -lc './bin/sidekiq -C ./config/sidekiq.yml'
EnvironmentFile=/home/%i/.env
Restart=always
KillMode=process
Type=simple

/etc/systemd/system/sidekiq@.service

systemctl enable sidekiq@myapp.service

root@development:~# ls -l /etc/systemd/system/tailored_core.target.wants/
total 0
... core-coordinator.service -> /etc/systemd/system/core-coordinator.service
... sidekiq@tailored_core.service -> /etc/systemd/system/sidekiq@.service
... unicorn@tailored_core.service -> /etc/systemd/system/unicorn@.service

Demo and bye

Made with Slides.com