Linux Service example

Here is a Linux service for Plant Waterify API:

/etc/systemd/system/plant-waterify-api.service

[Unit]
Description=Plant-Waterify API
After=network.target

[Service]
Type=simple
ExecStart=/home/jason/www-data/plant-waterify-api/plant-waterify-api.sh
TimeoutStartSec=0
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=default.target

 

This service runs a simple script to run the Go app:

plant-waterify-api.sh

#!/bin/bash
/home/jason/www-data/plant-waterify-api/plant-waterify-api -conf=/home/jason/www-data/plant-waterify-api/