Sandro Pischinger 67f7d13ef6 config: fix server->bind when more than 1 char
Currently the bind option in the configuration file defaults to '*' and
is read during startup in web.py. The value of the host variable  is
of type string, but the current code tries to iterate through it,
suppusedly to support multiple hosts.
This would work if the value was of type array, holding multiple strings
of hostnames (similar to [mqtt]->topics, which is currently not
possible.

When setting 'bind=localhost', the code iterates through 'localhost'
and tries to start a TCPSite with a host of 'l', then 'o', then 'c' and
so on but failes at the first 'l' already since it cannot be resolved.

This commit changes the behaviour of 'bind' to only expect one value,
namely a string of the host where to bind to.

This change does not require any config changes in current productions
setups: The default bind value of '*' is still handled correctly and any
other bind values with more than one character currently fail anyways.

Signed-off-by: Sandro Pischinger <mail@sandropischinger.de>
2025-05-04 17:27:10 +02:00
2025-01-20 13:54:22 -08:00
2024-08-21 20:51:25 -07:00
2025-03-10 13:58:33 -07:00
2025-01-20 12:41:47 -08:00
2024-05-09 20:00:00 -07:00
2024-05-09 20:00:00 -07:00
2025-03-08 15:34:30 -08:00
2025-03-09 21:20:55 -07:00
2025-03-05 16:11:40 -08:00
2025-04-06 10:49:30 -07:00
2025-04-28 22:06:42 -07:00

Meshview

node

This project watches a MQTT topic for meshtastic messages, imports them to a database and has a web UI to view them.

Samples of currently running instances:


Preparing

Requires python3.11 or above.

Clone the repo from GitHub:

git clone --recurse-submodules https://github.com/pablorevilla-meshtastic/meshview.git

Note


It is important to include the --recurse-submodules flag or the meshtastic protobufs won't be included.

Create a Python virtual environment:

cd meshview
python3 -m venv env

Install the environment requirements:

./env/bin/pip install -r requirements.txt

Install graphviz:

sudo apt-get install graphviz

Copy sample.config.ini to config.ini:

cp sample.config.ini config.ini

Edit config.ini to match your MQTT and web server settings:

nano config.ini

Example:

# Server Details
[server]
bind = *
port = 8081
tls_cert =
acme_challenge =

# Site Details
[site]
domain = https://www.bayme.sh
title = Bay Area Mesh
message = Real time data from around the bay area and beyond.

# Quick links enablement on site
nodes=True
conversations=True
everything=True
graph_lf=True
graph_ms=True
graph_mf=False
stats=True
net=True
map=True
top=True

# Map structure
map_top_left_lat=39
map_top_left_lon=-123
map_bottom_right_lat=36
map_bottom_right_lon=-121

# Note about how your weekly mesh runs. time and tag used for the system to track.
weekly_net_message= Weekly Mesh check-in. We will keep it open on every Wednesday from 5:00pm for checkins. The message format should be (LONG NAME) - (CITY YOU ARE IN) #MeshNet.
net_tag=#test

# MQTT Server configuration 
[mqtt]
server = mqtt.bayme.sh
topics = ["msh/US/bayarea/#", "msh/US/CA/mrymesh/#", "msh/US/CA/sacvalley" ]
port = 1883
username = meshdev
password = large4cats

# Database configuration 
[database]
connection_string = sqlite+aiosqlite:///packets.db

Running Meshview

Start the database:

./env/bin/python startdb.py

Start the web server:

./env/bin/python main.py

Note


You can specify a custom config file with the --config flag:

./env/bin/python startdb.py --config /path/to/config.ini
./env/bin/python main.py --config /path/to/config.ini

Open in your browser: http://localhost:8081/


Running Meshview with mvrun.py

  • mvrun.py starts both startdb.py and main.py in separate threads and merges the output.
  • It accepts the --config argument like the others.
./env/bin/python mvrun.py

Setting Up Systemd Services (Ubuntu)

To run Meshview automatically on boot, create systemd services for startdb.py and main.py.

Note


You need to change the "User" and "/path/to/meshview" for your instance of the code on each service.

1. Service for startdb.py

Create:

sudo nano /etc/systemd/system/meshview-db.service

Paste:

[Unit]
Description=Meshview Database Initializer
After=network.target

[Service]
Type=simple
WorkingDirectory=/path/to/meshview
ExecStart=/path/to/meshview/env/bin/python /path/to/meshview/startdb.py --config /path/to/meshview/config.ini
Restart=always
RestartSec=5
User=yourusername

[Install]
WantedBy=multi-user.target

2. Service for main.py

Create:

sudo nano /etc/systemd/system/meshview-web.service

Paste:

[Unit]
Description=Meshview Web Server
After=network.target meshview-db.service

[Service]
Type=simple
WorkingDirectory=/path/to/meshview
ExecStart=/path/to/meshview/env/bin/python /path/to/meshview/main.py --config /path/to/meshview/config.ini
Restart=always
RestartSec=5
User=yourusername

[Install]
WantedBy=multi-user.target

3. Enable and start the services

sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable meshview-db
sudo systemctl enable meshview-web
sudo systemctl start meshview-db
sudo systemctl start meshview-web

4. Check status

systemctl status meshview-db
systemctl status meshview-web

Tip


After editing .service files, always run:

sudo systemctl daemon-reload
S
Description
No description provided
Readme 7.6 MiB
Languages
Python 74.3%
HTML 24.7%
Shell 0.4%
JavaScript 0.3%
Dockerfile 0.2%