-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from MeshAddicts/refactor-20240708
Refactor 20240708
- Loading branch information
Showing
26 changed files
with
1,736 additions
and
1,213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ node_modules/ | |
.env | ||
|
||
backups/* | ||
caddy | ||
output/* | ||
mosquitto/data/* | ||
postgres/data/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
debug | ||
} | ||
|
||
localhost { | ||
root * /srv | ||
encode gzip | ||
file_server | ||
log { | ||
output file /var/log/caddy.log | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
|
||
from encoders import _JSONEncoder | ||
|
||
class DataRenderer: | ||
def __init__(self, config, data): | ||
self.config = config | ||
self.data = data | ||
|
||
def render(self): | ||
self.save_file("chat.json", self.data.chat) | ||
print(f"Saved {len(self.data.chat['channels']['0']['messages'])} chat messages to file ({self.config['paths']['data']}/chat.json)") | ||
|
||
nodes = {} | ||
for id, node in self.data.nodes.items(): | ||
if id.startswith('!'): | ||
id = id.replace('!', '') | ||
nodes[id] = node | ||
|
||
self.save_file("nodes.json", self.data.nodes) | ||
print(f"Saved {len(nodes)} nodes to file ({self.config['paths']['data']}/nodes.json)") | ||
|
||
self.save_file("telemetry.json", self.data.telemetry) | ||
print(f"Saved {len(self.data.telemetry)} telemetry to file ({self.config['paths']['data']}/telemetry.json)") | ||
|
||
self.save_file("traceroutes.json", self.data.traceroutes) | ||
print(f"Saved {len(self.data.traceroutes)} traceroutes to file ({self.config['paths']['data']}/traceroutes.json)") | ||
|
||
def save_file(self, filename, data): | ||
print(f"Saving {filename}") | ||
with open(f"{self.config['paths']['data']}/{filename}", "w", encoding='utf-8') as f: | ||
json.dump(data, f, indent=2, sort_keys=True, cls=_JSONEncoder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
services: | ||
caddy: | ||
image: caddy:latest | ||
ports: | ||
- 80:80 | ||
- 443:443 | ||
volumes: | ||
- ./caddy/data:/data/caddy | ||
- ./Caddyfile.dev:/etc/caddy/Caddyfile | ||
- ./output/static-html:/srv | ||
- ./public/images:/srv/images | ||
environment: | ||
- CADDY_AGREE=true | ||
restart: always | ||
|
||
postgres: | ||
image: postgres:latest | ||
volumes: | ||
- ./postgres/data:/var/lib/postgresql/data | ||
environment: | ||
- POSTGRES_PASSWORD=password | ||
restart: always | ||
|
||
mqtt: | ||
container_name: mqtt | ||
image: eclipse-mosquitto:latest | ||
ports: | ||
- 1883:1883 | ||
volumes: | ||
- ./mosquitto/data:/mosquitto/data:rw | ||
- ./mosquitto/config:/mosquitto/config:rw | ||
restart: always | ||
|
||
meshinfo: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
volumes: | ||
- ./config.json:/app/config.json | ||
- ./output:/app/output | ||
- ./templates:/app/templates | ||
environment: | ||
- PYTHONUNBUFFERED=1 | ||
- MQTT_HOST=mqtt | ||
- MQTT_PORT=1883 | ||
- MQTT_USERNAME=meshinfo | ||
- MQTT_PASSWORD=m3sht4st1c | ||
restart: always | ||
depends_on: | ||
- caddy | ||
- postgres | ||
- mqtt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.