Skip to content

Commit

Permalink
attempt to implement workaround for sudomesh/bugs#24 . fyi @bennlich
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpoelen committed Apr 1, 2018
1 parent e012bbc commit 07e82a8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
5 changes: 3 additions & 2 deletions create_exitnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ EOF

git clone https://github.com/${EXITNODE_REPO} /opt/exitnode
cp -r /opt/exitnode/src/etc/* /etc/
cp -r /opt/exitnode/src/opt/* /opt/
mkdir -p /var/lib/babeld
cp /opt/exitnode/l2tp_broker.cfg $TUNNELDIGGER_HOME/broker/l2tp_broker.cfg

Expand All @@ -157,15 +158,15 @@ sed -i.bak "s#interface=lo#interface=$ETH_IF#" $CFG
sed -i 's/dns-nameservers.*/dns-nameservers 8.8.8.8/g' /etc/network/interfaces.d/50-cloud-init.cfg
sed -i '/address/a \ \ dns-nameservers 8.8.8.8' /etc/network/interfaces.d/50-cloud-init.cfg



# start babeld and tunnel digger on reboot
systemctl enable sudomesh-gateway
systemctl enable tunneldigger
systemctl enable babeld
systemctl enable babeld-monitor

service sudomesh-gateway start
service tunneldigger start
service babeld start
service babeld-monitor start

reboot now
14 changes: 14 additions & 0 deletions src/etc/systemd/system/babeld-monitor.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=babeld-monitor
After=network.target auditd.service

[Timer]
OnCalendar=*:0/10

[Service]
Type=simple
ExecStart=/opt/babeld-monitor/babeld-monitor.sh

[Install]
WantedBy=timers.target

24 changes: 24 additions & 0 deletions src/opt/babeld-monitor/babeld-monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# This is a workaround for a suspected (babeld?) memory leak
# https://github.com/sudomesh/bugs/issues/24

set -e

date_last_error=$(sudo journalctl -u babeld -o short-iso | grep "Cannot allocate memory" | tail -n1 | awk '{print $1}' | xargs date -d )

date_last_started=$(sudo journalctl -u babeld -o short-iso | grep "Started babeld" | tail -n1 | awk '{print $1}' | xargs date -d )

if [[$date_last_error > $date_last_restart]]; then
echo "found [Cannot allocate memory] error since last babeld restart"
echo "babeld restarting..."
service babeld restart
echo "babeld restarted."
# add tunnel interfaces to babeld
echo "add tunnel interfaces to babeld..."
ip addr | tr ' ' '\n' | grep -E "l2tp[0-9]+$" | sort | uniq | xargs -L 1 babeld -a
echo "add tunnel interfaces to babeld done."
else
echo "found no [Cannot allocate memory] error since last babeld restart"
fi


1 comment on commit 07e82a8

@bennlich
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.