Manually run Thing binary from the command line:
Thing will log startup and running messages to standard output (and errors to standard error output).
Browse to http://localhost on Thing and see "Hello!" in browser.
We can set up a systemd script to automatically start and run your Thing on system startup as a service.
Create a new file /lib/systemd/system/thing.service with this content:
Adjust the script to use the correct /home/user directory path and binary name for your Thing (the blue items in the script).
The script will automatically restart Thing if it crashes or if the system restarts.
The script will log standard output/error to syslog. The log entries will be prefixed with [thing]. See next section to set up logging.
To install and start script:
To check on the service status, use:
Every Thing will output log messages, by default. While useful for debugging or monitoring, they maybe too voluminous for production. To disable logging, set thing.Cfg.LoggingEnabled = false before running.
(Sorry, no log-levels currently, only a big on/off switch)
When running Thing as a service, use rsyslog to capture standard output/error to the log file /var/log/thing.log.
Create a /etc/rsyslog.d/thing.conf configuration file with this content:
Restart rsyslog after adding configuration file:
You can restart Thing service and verify log message: