None of these are reliable options. You need to watch the logs to know when RNS is fully started and it's ok to start lxmd and NomadNet. To do that you need wrapper scripts that fork off the rnsd process and don't end themselves until the logs indicate that RNS is fully started. This allows you to use the systemd functionality for making sure the different services start in sequence, without having to rely on timers which will get flaky when RNS has to load a lot of path table entries on startup.
/etc/systemd/system/rnsd.service:
[Unit]
Description=Reticulum rnsd Service
After=network-online.target
Requires=network-online.target
StartLimitIntervalSec=60
StartLimitBurst=4
[Service]
Type=forking
ExecStart="/path/to/start_rnsd.sh"
ExecStop="/path/to/stop_rnsd.sh"
Restart=always
RestartSec=3
Nice=-10
Environment="PYTHONPATH='/home/rns/Reticulum':'/home/rns/LXMF':'/home/rns/NomadNet'"
WorkingDirectory=~
User=rns
Group=reticulum
[Install]
WantedBy=multi-user.target
start_rnsd.sh:
#!/bin/bash
set -e
LOG="/path/to/reticulum/logfile"
LOGLINES=0
if [ -f $LOG ]; then
LOGLINES=$(wc -l < $LOG)
fi
echo "Starting rnsd service"
export PYTHONPATH='/home/rns/Reticulum':'/home/rns/LXMF':'/home/rns/NomadNet'
python3 -m "RNS.Utilities.rnsd" --service --config "/home/rns/config/reticulum" &
echo "Waiting for rnsd service to fully start"
while true; do
NEWLOGLINES=$(wc -l < $LOG)
if [ "$NEWLOGLINES" -lt "$LOGLINES" ] ; then
# The log must have rotated since the start of the script
TAILCMD="cat $LOG"
else
TAILCMD="tail -n +$LOGLINES $LOG"
fi
if $($TAILCMD | grep -q -E "Started rnsd"); then
break
else
sleep 1
fi
done
echo "Started rnsd service"
stop_rnsd.sh
#!/bin/bash
set -e
LOG="/path/to/reticulum/logfile"
LOGLINES=0
if [ -f $LOG ]; then
LOGLINES=$(wc -l < $LOG)
fi
echo "Stopping rnsd service"
kill $MAINPID
echo "Waiting for rnsd service to fully shut down"
while true; do
NEWLOGLINES=$(wc -l < $LOG)
if [ "$NEWLOGLINES" -lt "$LOGLINES" ] ; then
# The log must have rotated since the start of the script
TAILCMD="cat $LOG"
else
TAILCMD="tail -n +$LOGLINES $LOG"
fi
if $($TAILCMD | grep -q -E "Saved known destinations to storage"); then
break
else
sleep 1
fi
done
echo "Stopped rnsd service"
Note that I run my node from source for easier development, so you'll have to change the command to run rnsd to whatever you need for your environment, and you can also remove the Environment=... line from the service file.
The lxmd service definition will look similar, but depending on the rnsd service:
After=rnsd.service
Requires=rnsd.service
And the start and stop scripts should grep for "Started lxmd" and "All interfaces detached", respectively (and naturally should be changed to run the right command).
For NomadNet, grep for "ready for incoming connections" and "Persisting LXMF state data to storage".
I have all of this abstracted in an Ansible playbook that I use to deploy my public node. I will release it at some point, once I get things cleaned up and documented a bit.