Rpc Update
This application automates the management of the RPC endpoint URL to ensure it is always connected to a synchronized Bor node. If the node encounters failures or is not fully synchronized, the application automatically performs an update to a new URL
This script was developed to provide dynamic management of the RPC URL for a Bor node. It performs periodic checks of the synchronization status of the Bor node, and if it is not fully synchronized, dynamically updates the RPC URL with a new value. During this process, it loads the existing configuration from the TOML file, updates the bor_rpc_url
parameter with a new URL, and performs the necessary checks to carry out the update automatically.
To set up an alternative URL, replace "https://your-bor-rpc" with your desired RPC URL.
Python and Requests Installation:
Make sure you have Python installed on your system. Open the terminal or command prompt. Execute the following command to install the requests
library:
Script Execution:
Save the Python script (Your_script.py
) in the directory of your choice. Place a file named "addresses.txt" in the same directory as the script, containing the addresses of the validators.
Run the Script:
In the terminal or command prompt, navigate to the directory where the script is located. Execute the script using the following command:
Results:
The script will periodically check the synchronization status of the Bor node. If the node is not fully synchronized, the script will dynamically update the RPC URL with the alternative URL you configured.
Managing with systemd unit.
Service Installation:
After making the changes, reload systemd to apply the modifications:
Start the Service:
Enable:
This unit file configures the Heimdall service to be restarted whenever there is a change in the configuration. Make sure to replace /path/to/reload-heimdall-service.sh
with the actual path to your Heimdall service reload script.
Monitoring Changes:
This script continuously monitors the TOML configuration file. If the file is modified, it automatically restarts the Heimdall service. Replace /path/to/your/heimdall-config.toml
with the actual path to your Heimdall configuration file.
Save the script with a meaningful name, for example,
heimdall-config.sh
.Make the script executable:
Run the script:
The script will enter into a loop and use
inotifywait
to watch for close_write events on the specified configuration file.When a change occurs in the configuration file, the script will restart the Heimdall service using
systemctl restart
.
Last updated