Differences between the leader and works

Hello,
I’ve been setting up a cluster of multiple reactors recently.
Could you tell me the configuration differences between the leader reactor and the workers?
For example, are there any differences in the source code?
And what about the differences in the environment configuration?

Hi @bob.zha,

Leaders have some additional software: mosquitto (MQTT broker), avahi for mDNS, the core app database is on the leader (sqlite3 db). That’s actually mostly all the software differences.

The source code is the same (GitHub - Pioreactor/pioreactor: Hardware and software for accessible, extensible, and scalable bioreactors. Built on Raspberry Pi., and GitHub - Pioreactor/pioreactorui: Web UI for the Pioreactor).

Here’s how the images are made too: CustoPiZer/workspace/scripts at pioreactor · Pioreactor/CustoPiZer · GitHub - some of this code is executed on leaders, some on workers. (Example)

The config.ini’s cluster.topology leader_hostname tells a Pioreactor if it’s a leader or not, or who the leader is in a cluster.

Are there any specific questions I can help answer?

Thank you,
I also noticed in the source code that you are monitoring the online status of _pio-worker._tcp.local. using ServiceBrowser(Zeroconf(), "_pio-worker._tcp.local.", listener). Could you tell me when and where this connection name is declared?

Right. On the workers, we place an avahi service file in /etc/avahi/services/ which will broadcast that a pio-worker service is available.

Zeroconf/avahi/mDNS can query local computers for that service, and we get a response from workers.

1 Like

“I encountered a problem: After installing the work image, if the Wi-Fi password changes, do I need to reinstall the image in order to access the network again?”

Maybe - it depends if you can still access the command line of the Pi. If you can (via ethernet for example), you can using nmcli to change the password on the wifi network:

sudo nmcli connection modify my_ssid_name wifi-sec.psk "new_password"

When I run the ps aux command on both the leader and work nodes, I found that the pio run monitor program is automatically started on the leader, but not on the work node.
Is this because the work node does not need it to start automatically? Also, after adding the work node to the leader, how can I obtain the hardware information of the work node?

monitor should be automatically started on all Pioreactors. If it’s not running on the worker, it must have failed to start. Try running sudo systemctl status pioreactor_startup_run@monitor.service on the worker to see what the error was. If there is no error, just try restarting the machine.

Right. It is because I did not attach the worker to the leader first.
But another quetion : When I run i2cdetect -y -q 1 on both the worker and the leader,the leader‘s HAT adress is 0x30, but the worker is 2c. The worker has failed to start the leds-automation , temperature-automation with the following error message

Unable to find i2c for LED driver. Is the Pioreactor HAT attached to the Raspberry Pi? Is the firmware loaded?

So there was a firmware change in the 24.8.22 release that moved the i2c address of the RP2040 from 0x30 to 0x2c. This changed solved an annoying bug that running i2cdetect would lock up the i2c channel - so that might explain what you are seeing!

If you are connected to the internet, you can run pio update firmware on the machines to get the latest firmware. FYI firmware rarely changes, so you don’t need to do this often.