[Unit] Description=Node.js Server After=network.target [Service] ExecStart=/usr/bin/node /home/alarm/myapp/index.js Type=simple Restart=always # Restart service after 10 seconds if node service crashes RestartSec=10 # Output to syslog StandardOutput=syslog StandardError=syslog SyslogIdentifier=nodejs-example User=alarm Environment=NODE_PORT=3000 [Install] WantedBy=multi-user.target