Skip to content

Commit 33a97d5

Browse files
authored
software: Gitify node-red-dashboard (#573)
Configure node-red to use the git repository as `userDir` so that changes to flows are visible in git. Here is the output of `git status` after making changed in the node-red editor: ![Screenshot From 2025-04-16 13-36-41](https://github.com/user-attachments/assets/a9f6b68f-1a04-44ff-84ce-0aa66bdc055d) `settings.js` file was copied from https://github.com/PlanktoScope/pallet-standard/blob/8fd23fded73b71d391d47a14ca79684cfcb6aeb7/packages/core/apps/planktoscope/node-red-dashboard/overlays/etc/nodered/settings.js Previously the setting file was setup using forklift https://github.com/PlanktoScope/pallet-standard/blob/8fd23fded73b71d391d47a14ca79684cfcb6aeb7/packages/core/apps/planktoscope/node-red-dashboard/overlays/etc/systemd/system/nodered.service.d/20-override.conf This is "bypassing" forklift as I'm not familiar with it yet, it is unclear if it will remain and in any case [dashboard 2](https://github.com/PlanktoScope/dashboard) will likely deprecate this. ![image](https://github.com/user-attachments/assets/8437615a-a2b4-4a15-9905-ad74c086be6a)
1 parent 57f8c84 commit 33a97d5

File tree

14 files changed

+8530
-4009
lines changed

14 files changed

+8530
-4009
lines changed

documentation/docs/community/contribute/tips-and-tricks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Make sure to replace `$planktoscope` with your PlanktoScope hostname, eg. `pksco
3838
<summary>On the PlanktoScope</summary>
3939

4040
```sh
41-
cd ~/Planktoscope
41+
cd ~/PlanktoScope
4242
# Enable Developer Mode
4343
./software/distro/setup/planktoscope-app-env/PlanktoScope/enable-developer-mode
4444
# Configure git
@@ -54,7 +54,7 @@ git config --global user.name "Your Name"
5454
# Create an SSH key for the PlanktoScope specifically
5555
ssh-keygen -t ed25519 -C "pi@$planktoscope" -f ~/.ssh/$planktoscope
5656
# Make the SSH key accepted by the PlanktoScope
57-
scp ~/.ssh/$planktoscope.pub pkscope:~/.ssh/authorized_keys
57+
ssh-copy-id -i ~/.ssh/$planktoscope.pub pi@$planktoscope
5858
```
5959

6060
```

software/distro/setup/planktoscope-app-env/PlanktoScope/enable-developer-mode

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ git fetch origin --filter=blob:none
1111
# "Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated."
1212
# https://git-scm.com/docs/git-reset#Documentation/git-reset.txt---mixed
1313
git reset --mixed $commit
14-
15-
mkdir $HOME/.ssh
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
# Start before mosquitto (provided via Forklift), to (hopefully) ensure that the Node-RED dashboard
3+
# is ready to catch all MQTT messages, such as messages sent by the Python backend right when it
4+
# starts (FIXME: make that unnecessary by allowing Node-RED to query the Python backend for any
5+
# information it needs later):
6+
Wants=forklift-apply.service
7+
Before=forklift-apply.service
8+
9+
[Service]
10+
ExecStart=
11+
ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS --settings /home/pi/PlanktoScope/software/node-red-dashboard/settings.js $NODE_RED_OPTIONS

software/distro/setup/planktoscope-app-env/node-red-frontend/install.sh

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
# Determine the base path for copied files
55
config_files_root=$(dirname "$(realpath "$BASH_SOURCE")")
6-
distro_setup_files_root=$(dirname "$(dirname "$config_files_root")")
76

87
# Get command-line args
98
hardware_type="$1" # should be either adafruithat, planktoscopehat, fairscope-latest, or segmenter-only
@@ -36,7 +35,6 @@ sudo ln -s /run/machine-name /var/lib/planktoscope/machine-name
3635
# default, we do `pip3 install` as the pi user. This makes the smbus2 module available to Node-RED.
3736
# FIXME: get rid of the Node-RED nodes depending on smbus! That functionality should be moved into
3837
# the Python backend.
39-
# Note: for bookworm we need to install the apt package; for bullseye there is no apt package
4038
if ! sudo apt-get install -y python3-smbus2; then
4139
sudo apt-get install -y python3-pip
4240
pip3 install smbus2==0.4.3
@@ -47,15 +45,13 @@ fi
4745
curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered |
4846
bash -s - --confirm-install --confirm-pi --no-init
4947

50-
# Select the enabled dashboard
51-
mkdir -p "$HOME"/.node-red
52-
cp "$HOME/PlanktoScope/software/node-red-dashboard/flows/$hardware_type.json" \
53-
"$HOME"/.node-red/flows.json
54-
mkdir -p "$HOME"/PlanktoScope
5548
cp "$HOME/PlanktoScope/software/node-red-dashboard/default-configs/$default_config.config.json" \
5649
"$HOME"/PlanktoScope/config.json
5750

58-
# Install dependencies in a way that makes them available to Node-RED
59-
cp "$HOME"/PlanktoScope/software/node-red-dashboard/package.json "$HOME"/.node-red/
60-
cp "$HOME"/PlanktoScope/software/node-red-dashboard/package-lock.json "$HOME"/.node-red/
61-
npm --prefix "$HOME"/.node-red update
51+
# Configure node-red
52+
npm --prefix "$HOME"/PlanktoScope/software/node-red-dashboard install
53+
sudo mkdir -p /etc/systemd/system/nodered.service.d
54+
sudo cp $config_files_root/30-override.conf /etc/systemd/system/nodered.service.d/30-override.conf
55+
56+
# Install dependencies to make them available to Node-RED
57+
npm --prefix "$HOME"/PlanktoScope/software/node-red-dashboard/$hardware_type install
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.backup
2+
.config.*.json
File renamed without changes.

0 commit comments

Comments
 (0)