Feed setup script, changeover to systemd service?

Discussion in 'Feeding' started by wiedehopf, Sep 6, 2019.

  1. wiedehopf

    wiedehopf Administrator Staff Member

    Hey James,

    i made a pull request on github some time ago asking if you would be interested in changing the setup script over to creating systemd services instead of using rc.local.

    Maybe you missed it?
    https://github.com/adsbxchange/adsb-exchange/pull/1

    Would be useful for logging so you see what the feed is doing.
     
  2. ktb

    ktb Member

    I'd also like to see the script changed to work with the way linux uses the systemd services. I'm feeding adsbx with an Eee-pc running 18.04 lubuntu. I'd rather not have to mess with the rc.local workaround.
     
    Last edited: Sep 7, 2019
  3. James

    James Guest

    I started moving the ADSBx image to systemd as well.
     
  4. James

    James Guest

  5. ktb

    ktb Member

    I deleted the rc.local connection to adsbx and the adsbx folder. After re-running the adsbx script and rebooting, feed started as normal. Thanks for the re-write James. If I have to start from "scratch" again, this new script will save time in getting the adsb feeder up and running.
     
  6. James

    James Guest

    Commented them out with # hope :D


    You should be able to do something like

    sudo systemctl enable adsbexchange-feed.service
    sudo systemctl enable adsbexchange-mlat.service

    sudo systemctl start adsbexchange-feed.service
    sudo systemctl start adsbexchange-mlat.service

    sudo systemctl status adsbexchange-feed.service
    sudo systemctl status adsbexchange-mlat.service
     
    ktb likes this.
  7. James

    James Guest

    Oh I see it worked!

    This systemd is all thanks to @wiedehopf
     
    ktb likes this.
  8. wiedehopf

    wiedehopf Administrator Staff Member

    You shouldn't normally need to start or enable the services, the script takes care of that.
    But you can restart the service if it's acting up or you can stop it if you chose to.

    Probably the most useful commands:

    sudo journalctl -eu adsbexchange-feed
    sudo journalctl -eu adsbexchange-mlat

    It will show you the logs associated with the services.
     
  9. ktb

    ktb Member

    Thanks for your work/time on this wiedehopf.
     
  10. Mark Richardson

    Mark Richardson New Member

    Every 15 minutes in sudo journalctl -eu adsbexchange-mlat

    Sep 15 14:44:45 piaware adsbexchange-mlat[518]: Sun Sep 15 14:44:45 2019 Receiver status: connected
    Sep 15 14:44:45 piaware adsbexchange-mlat[518]: Sun Sep 15 14:44:45 2019 Server status: ready
    Sep 15 14:44:45 piaware adsbexchange-mlat[518]: Sun Sep 15 14:44:45 2019 Receiver: 405.8 msg/s received 149.3 msg/s processed (37%)
    Sep 15 14:44:45 piaware adsbexchange-mlat[518]: Sun Sep 15 14:44:45 2019 Server: 0.0 kB/s from server 1.5kB/s TCP to server 0.0kB/s UDP to server
    Sep 15 14:44:45 piaware adsbexchange-mlat[518]: Sun Sep 15 14:44:45 2019 Results: 31.5 positions/minute
    Sep 15 14:44:45 piaware adsbexchange-mlat[518]: Sun Sep 15 14:44:45 2019 Aircraft: 18 of 24 Mode S, 57 of 61 ADS-B used

    Anything to see here?

    And thank you wiedehopf for your time and effort!
     
  11. wiedehopf

    wiedehopf Administrator Staff Member

    It's just statistics that the mlat-client outputs every 15 min.
    The "Results" line might be most interesting showing 30 mlat positions per minute being sent to you by the server.
     
  12. Mark Richardson

    Mark Richardson New Member

    Is that good or bad? :)
     
  13. Nummer378

    Nummer378 New Member

    I just re-ran the setup.sh script in order to migrate to the new systemd services. Everything seemed to work, the services are running but apparently I'm constantly disconnected from the network (both MLAT and feed service). No idea what's wrong, any ideas? I've also disappeared from the MLAT statistics, where I was synchronized just fine until I re-ran the setup.sh script today. The site adsbexchange /myip/ shows my IP constantly connecting and disconnecting.

    I'm using a raspberry pi 3b+ with raspbian buster, installed adsbexchange via the github repo /adsb-exchange. Updated the git repo just today to current master and executed the setup script. I already had the feed installed using a slightly older version of the repo (just before the introduction of systemd services).

    # sudo service adsbexchange-mlat status

    Code:
    Sep 15 16:57:47 raspberrypi3b adsbexchange-mlat[446]: Sun Sep 15 16:57:47 2019 Connected to multilateration server at feed.adsbexchange dotcom:31090, handshaking
    Sep 15 16:58:23 raspberrypi3b adsbexchange-mlat[446]: Sun Sep 15 16:58:23 2019 Lost connection to feed.adsbexchange dotcom:31090
    Sep 15 16:58:23 raspberrypi3b adsbexchange-mlat[446]: Sun Sep 15 16:58:23 2019 Reconnecting in 30.0 seconds
    Sep 15 16:58:53 raspberrypi3b adsbexchange-mlat[446]: Sun Sep 15 16:58:53 2019 Connected to multilateration server at feed.adsbexchange dotcom:31090, handshaking
    Sep 15 16:59:54 raspberrypi3b adsbexchange-mlat[446]: Sun Sep 15 16:59:54 2019 Disconnecting from feed.adsbexchange dotcom:31090: No data (not even keepalives) received for 60 seconds
    Sep 15 17:00:26 raspberrypi3b adsbexchange-mlat[446]: Sun Sep 15 17:00:26 2019 Connected to multilateration server at feed.adsbexchange dotcom:31090, handshaking
    Sep 15 17:01:26 raspberrypi3b adsbexchange-mlat[446]: Sun Sep 15 17:01:26 2019 Disconnecting from feed.adsbexchange dotcom:31090: No data (not even keepalives) received for 60 seconds
    Sep 15 17:01:34 raspberrypi3b adsbexchange-mlat[446]: Sun Sep 15 17:01:34 2019 Connected to multilateration server at feed.adsbexchange dotcom:31090, handshaking
    
    # sudo service adsbexchange-feed status

    Code:
    Sep 15 17:02:12 raspberrypi3b adsbexchange-feed[443]: Connected to feed.adsbexchange dotcom:30005
    Sep 15 17:02:17 raspberrypi3b adsbexchange-feed[443]: 2019/09/15 17:02:17 socat[1605] E write(6, 0xd1920, 1002): Broken pipe
    Sep 15 17:02:17 raspberrypi3b adsbexchange-feed[443]: Disconnected
    Sep 15 17:02:48 raspberrypi3b adsbexchange-feed[443]: Connected to feed.adsbexchange dotcom:30005
    Sep 15 17:02:53 raspberrypi3b adsbexchange-feed[443]: 2019/09/15 17:02:53 socat[1630] E write(6, 0x1bc5920, 1014): Broken pipe
    Sep 15 17:02:53 raspberrypi3b adsbexchange-feed[443]: Disconnected
    Sep 15 17:03:24 raspberrypi3b adsbexchange-feed[443]: Connected to feed.adsbexchange dotcom:30005
    Sep 15 17:03:28 raspberrypi3b adsbexchange-feed[443]: 2019/09/15 17:03:28 socat[1663] E write(6, 0xd8f920, 1005): Broken pipe
    Sep 15 17:03:28 raspberrypi3b adsbexchange-feed[443]: Disconnected
    
    Repeats in an infinite loop. I've restarted the system, checked all network connections, feeds to other sites all work ok. I've also switched IP adresses in case I got mistakenly banned. Any help on how I get it working again?
     
  14. Mark Richardson

    Mark Richardson New Member

    Mine is similar....with the results from sudo service adsbexchange-feed status


    (and I'd post it but it says it's "spam like"....so it's attached as a screenshot)
    :(
     

    Attached Files:

    Nummer378 likes this.
  15. wiedehopf

    wiedehopf Administrator Staff Member

    That looks fine. Some disconnects are to be expected, you just didn't see them before with the old version of the script.
     
  16. wiedehopf

    wiedehopf Administrator Staff Member

    Let's check:
    cat /etc/default/adsbexchange

    pgrep -a socat
    pgrep -a adsbexchange
     
  17. Nummer378

    Nummer378 New Member

    # cat /etc/default/adsbexchange
    Code:
    RECEIVERPORT="30005"
    USER="AnonymousSmallAntenna"
    RECEIVERLATITUDE="<redacted>"
    RECEIVERLONGITUDE="<redacted>"
    RECEIVERALTITUDE="211m"
    RESULTS="beast,connect,localhost:30104"
    MLATSERVER="feed.adsbexchange dotcom:31090"
    
    # pgrep -a socat
    Code:
    2440 /usr/bin/socat -u TCP:localhost:30005 TCP:feed.adsbexchange dotcom:30005
    # pgrep -a adsbexchange
    Code:
    2315 /bin/sh /usr/local/bin/adsbexchange-feed.sh
    (The dotcom is in fact . com, because I'm not allowed to posts links)
     
  18. wiedehopf

    wiedehopf Administrator Staff Member

    Let's check this then:
    echo | nc -w 5 -q 1 localhost 30005 > /dev/null; echo $?

    It will show a 0 if the port 30005 is open. (data source)

    I'm puzzled, this all looks perfectly fine i don't know why the connection would fail.

    You can also try this on the console, it should display more info for the socat part

    socat -d -d -u TCP:localhost:30005 TCP:feed.adsbexchange.com:30005

    Tested myself, even if i have one connection already open, a second connection is not a problem.
     
    Last edited: Sep 15, 2019
  19. Nummer378

    Nummer378 New Member

    Yeah, from my point of view the server is actively rejecting my data - I can connect, but get disconnected (by server) a few seconds later. My client reconnects and the loop repeats. Major question is why?

    It's open. See attached image.
     

    Attached Files:

  20. wiedehopf

    wiedehopf Administrator Staff Member

    Let's check this output as well to see some more information from socat:

    socat -d -d -u TCP:localhost:30005 TCP:feed.adsbexchange.com:30005