Aktor: spacermake (Primary-Secondary mit Nutzungsprotokoll)
Dieser Aktor ist eine Zuarbeit vom Makerspace Bocholt. Der Aktor agiert zusammen mit Aktor: Machine Logger (CSVlog) und dient dazu, sekundär eingeschaltene Geräte im Log zu erfassen und Verbräuche zu tracken. Der Aktor schickt außerdem informative Anzeigeinformationen an ggf. installierte FabReader oder FabCounter-Anzeigen. spacermake greift deshalb unter anderem auf die bestehende FabFire Adapter Konfiguration (config.toml
) zurück.
spacermake installieren
Wir klonen das Projekt:
mkdir -p /opt/fabinfra/adapters/
git clone https://github.com/LastExceed/spacermake.git
cd spacermake/
Vor dem Kompilieren müssen wir noch ein paar Pfade für Konfigurations- und Logdateien anpassen. Das Script ist aktuell nicht optimal konfigurierbar und muss deshalb vor dem Nutzen und geeignet angepasst und erst dann kompiliert werden!
vim /src/main.rs
static ref SLAVES_BY_MASTER: HashMap<String, HashSet<String>> = parse_toml_file("master-slave_relations.toml");
static ref SLAVE_PROPERTIES: HashMap<String, [bool; 3]> = parse_toml_file("slave_properties.toml");
static ref MACHINE_IDS: HashMap<String, String> = parse_toml_file::<toml::Table>("/opt/fabinfra/adapters/fabfire_adapter/config/config.toml")
vim /src/utils/logs.rs
.open("/opt/fabinfra/adapters/spacermake/machinelog.csv")?
# und weiter unten:
.open("/opt/fabinfra/adapters/spacermake/machinelog_debug.csv")?
cd /opt/fabinfra/adapters/spacermake/target/release/
touch master-slave_relations.toml
touch slave_properties.toml
mkdir -p /root/fabfire/
touch /root/fabfire/config.toml
touch /root/machinelog.csv
touch /root/machinelog_debug.csv
Wir installieren Rust, falls noch nicht vorhanden ist:
# Wir installieren nun das aktuelle Rust per rustup (als normaler Nutzer). Rustup erlaubt das flexible Installieren beliebiger Rust-Versionen
curl https://sh.rustup.rs -sSf | sh
# cargo in .bashrc einfügen und Umgebung neu laden
echo 'source "$HOME/.cargo/env"' >> ~/.bashrc
source ~/.bashrc
# wir prüfen, ob wir die aktuelle Rust Version haben
rustup show
# oder installieren sie ...
rustup install stable
rustup default stable
Dann erzeugen wir die Binary:
cd /opt/fabinfra/adapters/spacermake/
cargo build --release
spacermake konfigurieren und testen
cd /opt/fabinfra/adapters/spacermake/target/release/
touch master-slave_relations.toml
touch slave_properties.toml
mkdir -p /root/fabfire/
touch /root/fabfire/config.toml
touch /root/machinelog.csv
touch /root/machinelog_debug.csv
Wir prüfen manuell, ob die Binary startet:
/opt/fabinfra/adapters/spacermake/target/release/spacermake
spacermake als systemd Service
sudo vim /etc/systemd/system/spacermake.service
[Unit]
Description=FabAccess Primary-Secondary Actor with usage log protocol
Require=network-online.target
After=network-online.target
[Service]
Type=simple
User=bffh
Group=bffh
ExecStart=/opt/fabinfra/adapters/spacermake/target/release/spacermake
Restart=always
WorkingDirectory=/opt/fabinfra/adapters/spacermake
[Install]
WantedBy=multi-user.target
Wir aktualisierne den Daemon, aktiveren und starten den Dienst dann:
sudo systemctl daemon-reload
sudo systemctl enable spacermake.service --now
Die Logs finden wir dann mit:
sudo journalctl -f -u spacermake.service