Linux’s init system
Install
Sudo pacman -S systemd
Systemctl
Software to configure the system’s OS Service that run at startup.
systemctl enable service
to enable autostart of the servicesystemctl disable service
systemctl start service
runs the servicesystemctl restart service
Creating Services
vim /etc/systemd/system/myservice.service
[Unit]
Description=Serve site using npx serve
After=network.target
[Service]
Type=simple
WorkingDirectory=/path-to-work-with
ExecStart=/command-to-run
Restart=always
RestartSec=10
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
sudo systemctl enable myservice.service
sudo systemctl start myservice.service
Creating Userland Services
apt install dbus-user-session dbus
reboot
mkdir -p ~/.config/systemd/user
- vim
~/.config/systemd/user/myservice.service
- Write the service file here
systemctl