I'm constantly forgetting how to write and install these. Here's my crib sheet.
$ sudo vim /lib/systemd/system/name_of_service.service
[Unit]
Description=Name of Service
Wants=network-online.target
[Service]
Type=simple
User=someuser
Group=somegroup
Restart=always
RestartSec=3sec
Environment="SOME_VAR=some value"
Environment="SOME_OTHER_VAR=some other value"
ExecStart=/path/to/some/executable arg1 arg[n]
# For `systemd --version` >= 236:
StandardOutput=file:/path/to/activity.log
StandardError=append:/path/to/persisted/error.log
[Install]
WantedBy=multi-user.target
$ sudo systemctl enable name_of_service.service
$ sudo service name_of_service [start|stop|restart]
$ service name_of_service status