# Systemd
|  | **Systemd** is a software suite that provides an array of system components for Linux operating systems. The main aim is to unify service configuration and behavior across Linux distributions. Its primary component is a "system and service manager" – an init system used to bootstrap user space and manage user processes. It also provides replacements for various daemons and utilities, including device management, login management, network connection management, and event logging. The name systemd adheres to the Unix convention of naming daemons by appending the letter d. It also plays on the term "System D", which refers to a person's ability to adapt quickly and improvise to solve problems. |
|-|-|
| | wikipedia:: [Systemd](https://en.wikipedia.org/wiki/Systemd) |
Newest init system, largely replacing [[init (SysV)]]
![[nix Services, Processes, & init System#systemd vs init(SysV)]]
- systemd-analyze
- how long OS took to boot
- systemd-analyze blame
- how long each service took to start
- systemctl
- list services running
- systemctl --type=service
- systemctl start myservice.service
- systemctl stop myservice.service
- systemctl restart myservice.service
- systemctl reload myservice.service
- sudo systemctl reload-or-restart application.service
- systemctl enable myservice.service
- To start a service at boot, use the enable command
- Keep in mind that enabling a service does not start it in the current session. If you wish to start the service and enable it at boot, you will have to issue both the start and enable commands.
- systemctl disable myservice.service
- Stops it from starting on boot
- systemctl status myservice.service
- Create systemd service unit file
- https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
- https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04
- https://www.baeldung.com/spring-boot-app-as-a-service
- Create a script named your-app.service using the following example and put it in /etc/systemd/system directory:
- E.g. for my NeighborShare App (with only some environment variables):
- \[Unit\] Description=NeighborShare Spring Boot Web Application After=syslog.target \[Service\] WorkingDirectory=/home/neighborshare/neighbor-share User=neighborshare Environment="DB\_HOST=localhost:3306" Environment="DB\_URL=neighbor-share" ExecStart=/usr/bin/java -jar /home/neighborshare/neighbor-share/neighborshare-0.0.1-SNAPSHOT.jar SuccessExitStatus=143 \[Install\] WantedBy=multi-user.target
- The only way I could get environment variables to work was just to list them all in the service like above