disabled buffering in python

Buffering makes the systemd journal not show the logs at the right time.
And changed the systemd service file so that the new batman and bridge
interfaces are deleted when naxalnet.service is stopped. Also simplified
the Stopping section in the README because of this change.
This commit is contained in:
Pranav Jerry 2021-08-16 18:56:17 +05:30
parent 397269823d
commit d18160c46c
No known key found for this signature in database
GPG Key ID: F1DCDC4FED0A0C5B
3 changed files with 15 additions and 15 deletions

View File

@ -19,4 +19,4 @@ uninstall:
clean:
rm -rf build naxalnet.egg-info
rm -rf build naxalnet.egg-info **/__pycache__

View File

@ -51,6 +51,7 @@ with anyone currently at risk of death in overcrowded prisons.
- two or more computers, or laptops with WiFi adapter, called nodes
- systemd-resolved (optional, for DNS)
- batctl (optional, for debugging)
- python pip (optional, for uninstalling)
## Installing
@ -112,6 +113,7 @@ To start naxalnet, do the command on all the nodes:
sudo systemctl start naxalnet.service
```
This will start a mesh network and connect to all nodes.
To test if it works, run `sudo batctl n -w` and check for
nodes. If there are any nodes, your network is up.
@ -152,10 +154,7 @@ sudo systemctl disable naxalnet.service
### Stopping the service
```sh
# Stop the services
sudo systemctl stop naxalnet systemd-networkd systemd-resolved iwd
# Delete the virtual interfaces created by naxalnet
sudo networkctl delete bat0 bridge0
```
If your distribution uses NetworkManager, starting `naxalnet.service`

View File

@ -1,16 +1,11 @@
# naxalnet systemd service
# The naxalnet systemd service
# See man:systemd.service(5) and man:systemd.unit(5)
# before editing this file.
[Unit]
Description=Naxalnet
Description=Setup mesh networks
Requires=systemd-networkd.service
Requires=iwd.service
Wants=systemd-resolved.service
# naxalnet does not reload networkd, so networkd
# should be started only afer naxalnet exits.
# This should be changed when naxalnet becomes
# a daemon.
Before=systemd-networkd.service
After=iwd.service
# Stops NetworkManager and wpa_supplicant if already running
Conflicts=NetworkManager.service
@ -22,16 +17,22 @@ After=wpa_supplicant.service
Type=oneshot
RemainAfterExit=yes
Restart=on-failure
# Probably not needed now
RestartSec=2sec
# IWD takes some time to find devices.
# If naxalnet is run before iwd finds devices,
# naxalnet cannot start a mesh network.
# Without the delay, naxalnet could not detect the second
# device while testing.
# naxalnet cannot start a mesh network but exits without errors.
# TODO: Remove this line when naxalnet becomes a daemon.
ExecStartPre=/usr/bin/sleep 2
ExecStart=/usr/bin/naxalnet
# Reload systemd-networkd after naxalnet exits
ExecStartPost=/usr/bin/systemctl reload-or-restart systemd-networkd.service
# Delete the interfaces created
ExecStopPost=/usr/bin/networkctl delete bridge0 bat0
# Make python flush messages the moment print() is called.
# Without this env variable, python stores output in a
# buffer before flushing to stdout. But this is not needed
# when naxalnet runs as a systemd service.
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=multi-user.target