add README
e031f041
1 file(s) · +46 −0
| 1 | + | # Pi Widget |
|
| 2 | + | ||
| 3 | + |  |
|
| 4 | + | ||
| 5 | + | This little Golang server can be used as a starting point to display your Raspberry Pi stats or any other information you want to display. For my case it also shares information about my [IPFS](https://ipfs.io) node. |
|
| 6 | + | ||
| 7 | + | It uses some simple functions to get the data and then sends it through a server-sides events endpoint called `/events`. There’s a separate `index.html` file that handles the data and renders it on the page. For ease or editing I have made this file embedded so it will be included during the build process. |
|
| 8 | + | ||
| 9 | + | ## Usage and Deployment |
|
| 10 | + | ||
| 11 | + | If you plan to use this for yourself then you will likely want to remove the IPFS stats code from the repo (unless you too happen to be a nerd like me and enjoy messing with that stuff). |
|
| 12 | + | ||
| 13 | + | Building is pretty straight forward, however you will want to make sure you have the right target build using the following command: |
|
| 14 | + | ||
| 15 | + | ``` |
|
| 16 | + | GOOS=linux GOARCH=arm GOARM=6 go build -o ~/pi-widget . |
|
| 17 | + | ``` |
|
| 18 | + | ||
| 19 | + | You can either build this on device or move it over via SMTP. Once on the Pi it can be spun up simply by running `./pi-widget`. To make this more persistent to you can set up a service like so: |
|
| 20 | + | ||
| 21 | + | 1. Make a new file under `/etc/systemd/user/pi-widget.service` and put the following contents inside. |
|
| 22 | + | ``` |
|
| 23 | + | [Unit] |
|
| 24 | + | Description=A little Pi Widget |
|
| 25 | + | Documentation=https://stevedylan.dev |
|
| 26 | + | After=network.target |
|
| 27 | + | ||
| 28 | + | [Service] |
|
| 29 | + | Type=simple |
|
| 30 | + | ExecStart=/home/steve/pi-widget |
|
| 31 | + | Restart=on-failure |
|
| 32 | + | KillSignal=SIGINT |
|
| 33 | + | ||
| 34 | + | [Install] |
|
| 35 | + | WantedBy=multi-user.target |
|
| 36 | + | ``` |
|
| 37 | + | ||
| 38 | + | 2. Run the following commands to enable, run, and persist the daemon |
|
| 39 | + | ||
| 40 | + | ``` |
|
| 41 | + | systemctl --user enable pi-widget |
|
| 42 | + | systemctl --user start pi-widget |
|
| 43 | + | loginctl enable-linger $USER |
|
| 44 | + | ``` |
|
| 45 | + | ||
| 46 | + | With the daemon running out of port `4321` you can setup a [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/)pointing to `http://localhost:4321` and have a working site with your stats! |