-
Notifications
You must be signed in to change notification settings - Fork 5
Setup Backend
ReefSpy edited this page Apr 8, 2024
·
4 revisions
It is assumed the git repository was cloned to the home directory, so lets start there:
cd ~
create installation directory:
sudo mkdir /usr/local/bin/reefberrypi
Create a Python virtual environment, activate it, and install Python dependencies from requirements.txt:
sudo python -m venv ReefberryPi/controller/venv
source ReefberryPi/controller/venv/bin/activate
sudo python -m pip install -r ReefberryPi/controller/requirements.txt
Compile the source files to a single executable and deactivate the virtual environment:
cd ReefberryPi/controller
pyinstaller --onefile RBP_controller.py
deactivate
copy executable to the installation directory:
sudo cp dist/RBP_controller /usr/local/bin/reefberrypi
create an initial config.ini file:
sudo nano /usr/local/bin/reefberrypi/config.ini
Enter the following values, and save (be sure to add the InfluxDB API Token you copied earlier!):
[global]
appuid =
influxdb_host = http://localhost:8086
influxdb_org = reefberrypi
influxdb_token = <<REPLACE_WITH_YOUR_TOKEN>>
mqtt_broker_host = localhost
mysql_host = localhost
mysql_user = pi
mysql_password = reefberry
mysql_database = reefberrypi
mysql_port = 3306
flask_port = 5000
Give ownership of the installation directory to user pi :
sudo chown -R pi: /usr/local/bin/reefberrypi/
Setup the Reefberry Pi service:
sudo cp reefberrypi.service /etc/systemd/system/
sudo systemctl enable reefberrypi.service
sudo systemctl start reefberrypi.service
Check status of ReefberryPi service:
sudo systemctl status reefberrypi