title: How to automatically restart systemd service on failure?
body: <p>I have written this service that runs TCP server using node.js to take data from micro controller to mysql server.</p>
  
  <pre><code>root@DietPi:~# sudo cat /lib/systemd/system/mysqlwifi.service 
   [Unit]
   Description=MySQL exampledb update
   After=multi-user.target
   After=network-online.target
   Wants=network-online.target
  
   [Service]
   Type=idle
   ExecStart=/usr/bin/node /home/dietpi/node_server/mysqlwifi.js &gt; /home/dietpi/node_server/mysqlwifi.log 2&gt;&amp;1
  
   [Install]
   WantedBy=multi-user.target
  root@DietPi:~#
  </code></pre>
  
  <p>Since this service is critical to push data to mysql i want it to automatically restart on failure. I also want to know how can I send an email on each failure or when service comes back live.</p>