Join our first global LoRaWAN developer conference Get Tickets
Home Labs Stories What next after the first run of your gateway?

WHAT NEXT AFTER THE FIRST RUN OF YOUR GATEWAY?

image story

ABOUT THIS STORY


Posted on Oct. 1, 2017



Intermediate
1 Hour

Introduction


So, you have succesfully configured your homebrew gateway with poly_pkt_fwd or mp_pkt_fwd - it works, but how to build a stable gateway?

First step would be to ensure the packet forwarder runs at boot and recovers after an error. I depend on systemd - this is used by default on debian jessie and above.

DigitalOcean have some great tutorials online and I used this one for the basis of my implementation:

https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units

I know that TTN has halted development on the go version of pkt_fwd, but I find it useful and works well on my homebrew based on RAK831 and the FriendlyArm NanoPi Neo running ubuntu 16.04.3 LTS. The solution described below will work on any Raspberry PI running debian jessie or later with any of the compatible gateway boards, running any of the versions of packet forwarder.

So, systemd requires a script in /lib/systemd/system - here is mine:

/lib/systemd/system/pkt_fwd_go.service
[Unit]
Description=manage go version of packet forwarder

[Service]
ExecStart=/opt/pkt_fwd_go/packet-forwarder-linux-arm-default-native start --config /opt/pkt_fwd_go/.pktfwd.yml
StandardOutput=syslog
StandardError=syslog
Restart=always

[Install]
WantedBy=multi-user.target

Having created this file, run:
sudo systemctl daemon-reload
Start the packet forwarder with:
sudo systemctl pkt_fwd_go
Go fill your coffee cup, wait a minute, then try:
sudo systemctl status pkt_fwd_go
Then run the following to ensure that the packet forwarder starts at each boot:
sudo systemctl enable application.service

Please read the DigitalOcean howto for an explanation of these commands.

"WantedBy= multi-user.target" ensure the system waits until it reaches the status of mult-user login before attempting to start the packet forwarder.

There is a problem with the go version of packet forwarder where it hangs after some use. The "Restart=always" line in the service script handles this and my gateway has been running for the past week, without my intervention.

Note that I piped the standard and error output of the packet forwarder to syslog. I use rsyslog and logrotate to manage the size of this output. By default, I backup syslog each day and keep the last 7 days logs on the system, so the syslog files in my /var/log folder looks like this:

-rw-r-----  1 syslog adm    1097921 Oct  1 12:09 syslog
-rw-r-----  1 syslog adm    4619057 Oct  1 06:25 syslog.1
-rw-r-----  1 syslog adm     355075 Sep 30 06:25 syslog.2.gz
-rw-r-----  1 syslog adm     652631 Sep 29 06:25 syslog.3.gz
-rw-r-----  1 syslog adm     521922 Sep 28 06:25 syslog.4.gz
-rw-r-----  1 syslog adm     342831 Sep 27 06:25 syslog.5.gz
-rw-r-----  1 syslog adm     432784 Sep 26 06:25 syslog.6.gz
-rw-r-----  1 syslog adm     265346 Sep 25 06:25 syslog.7.gz

I hope this helps some people out there - please add comments if you have any questions.