MaaS - Server Implementation
Implementation of Matomat As A Service using Golang.
Work in progress, feel free to contribute.
Biggest TODOs
- Properly set MQTT message format
(for not so big TODOs simply grep for TODO, the result will speak for itself ^^)
Requirements
- golang version 1.7+
- sqlite3
- ~440MB RAM (measured using
memusg
=> see "Reference Links")
Installation
- Pull all go dependencies using
go get ./...
- Create a sqlite3 db at the desired location using
sqlite3 matomat.db < schema.sql; sqlite3 matomat.db < initial_data.sql
- Create SSL certificate data (public and private cert parts)
- Create a
config.yml
from config.yml.template
and fill it with real values
- Run the server :-)
Initial user info
Use admin
with password admin
for initial login. Create new user and delete user admin
afterwards.
(Hash for the password in initial_data.sql
was created with bcrypt using 10 rounds)
Shutting down the server
Send a SIGTERM or SIGINT, server will then shutdown after a grace period configured in config.yml
.
Local testing
Easy creation of a self signed certificate for local TESTING.
go run $GOROOT/src/crypto/tls/generate_cert.go --rsa-bits 4096 --host 127.0.0.1,::1,localhost --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h
Event Dispatcher
Example MQTT Messages
'matomat;item-consumed;1;2;Bier;100;1;1556827023'
'matomat;item-consumed;1;1;Club Mate;100;1;1556827042'
Reference Links