Systemd is a Linux software suite that handles system services (daemon) and timers; it enables you to start, stop and restart your application using systemctl command. It can also start your application during operating systems boot-up sequence.
Note that you will need to have root or sudo privileges for this operation.
To create a systemd unit file, create a service file inside the directory /etc/systemd/system/. The filename must end with .service for example:
Below is the sample template for a systemd unit file.
# Systemd unit file for example application [Unit] Description=Service Description After=syslog.target network.target [Service] Type=simple Restart=always RestartSec=30s User=user Group=group WorkingDirectory=/path/to/working-directory ExecStart=/path/to/working-directory/./golang-application [Install] WantedBy=multi-user.target