Web view hosted on a different server | transfer .json files to webspace

Hello,

I want to make the local web view of dump1090-fa available to a broader audience. To reduce stress on the rpi and the internet connection and enabling SSL on the site (this is not possible for the rpi in my setup) on a different webspace.

Putting all the static files on there of course is no problem. Modifying the static files to reload the changing data from the rpi also works, but of course not with SSL enabled.

Therefore, I thought maybe the best idea is to also put the .json files, dump1090-fa creates onto the webspace. Mounting the corresponding webspace folder to the filesystem of the rpi is no problem, but then I don’t know how to move the .json files to the new mount point.

It has to go this way, as the options on the webspace are very limited. Installing dump1090-fa there e.g. is no option.

Does anybody have a solution for this problem or maybe even more clever idea for that problem.

Look at /lib/systemd/system/dump1090-fa.service (specifically the --write-json command-line argument - this controls where dump1090-fa will write the json files).

The best way to override that service file is to create your own copy in /etc/systemd/system/ as any changes to the copy in /lib will be lost on package upgrade.

Be aware that the main aircraft.json is rewritten once a second so if you’re writing it to a NFS mount or something like that then that’s going to be continuous traffic regardless of how many clients there are. An alternative option might be to put a reverse proxy in front of the Pi.

Isn’t there a way to run dump1090 as a net-only version getting the information from the RPi and show it on a different device?

If this is possible, dump1090 could be installed additionally getting the data from the remote RPi

Thank you for your answers.

@foxhunter: I’m aware of that possibility. I have used it in the past for different purposes. But as noted above, the webserver is very limited. I can not install dump1090 over there. Only possibility of access is FTP.

@obj: Thank you for your explanations. Works as excpected. Dump1090-fa writes the files to the new directory. But if I mount the foreign FTP file system it can no write anymore. I guess it has something to do with permissions as curlftpfs always mounts the ftp as root. Hence, I have tried to start dump1090-fa as root, but no luck.
Is there a log for dump1090-fa?

Thanks

Edit: Here the output of curlftpfs when dump1090-fa wants to write the .json file
ftpfs: operation ftpfs_getattr failed because No such file or directory unique: 56, error: -2 (No such file or directory), outsize: 16 unique: 57, opcode: CREATE (35), nodeid: 1, insize: 77, pid: 12387 create flags: 0xc2 /receiver.json.trhTeg 0100600 umask=0022 ftpfs: operation ftpfs_open failed because Operation not supported unique: 57, error: -95 (Operation not supported), outsize: 16 unique: 58, opcode: LOOKUP (1), nodeid: 1, insize: 58, pid: 12387 LOOKUP /stats.json.zED5Gi getattr /stats.json.zED5Gi

That looks like some problem with the temporary file; dump1090 updates the file by writing the new contents to a temporary file, then atomically renaming that file to the well-known path. I don’t know whether curlftpfs provides POSIX-compliant filesystem semantics or not.

dump1090 logs are available via systemd → journal → syslog; however I don’t think it’ll log anything if the file creation/write/rename fails.

So you started it as root, but it still didn’t work?

Write your own service that copies the aircraft.json every second.
receiver.json only needs to be copied over once, then it’s good until you change settings.

Yes, but in the meantime I added the option “allow_others” when mounting ftpfs. So this should eliminate the permissions problem. At least I can create and delete files with the “pi” and “root” user without any problem.

Ok, thank you. I quess too that there might be a problem with the ftpfs not offering enough options. I will try to write my own service to copy the file… just have to figure out how to do this :wink:

Generic systemd service · wiedehopf/adsb-wiki Wiki · GitHub

That’s some basic guidance on how to add a systemd service.

I’d advice a simple bash script started by that service.

#!/bin/bash

cp /run/dump1090-fa/receiver.json /tmp/receiver.json

while wait
do
    sleep 1 &
    cp /run/dump1090-fa/aircraft.json /tmp/aircraft.json || true
done

You can keep it even simpler:

while sleep 1
do
    cp ......
done

Anyhow … up to you.
The first example will keep a steady 1 second rythm granted the cp operation doesn’t take longer than a second.
The simpler version will not keep a 1 second rythm but rather the duration of the cp operation will be added to the interval.

Thank you, I will have a look into that…

But one further question: what about the history .json files? Aren’t they necessary for the tracks?

Well yes they are.
Can’t have everything :stuck_out_tongue_winking_eye:

Maybe just get some server that can run dump1090 :wink:

Because i’m in a good mood:

#!/bin/bash

TARGET=/asdf/ftpdirectory

cp /run/dump1090-fa/receiver.json "$TARGET/receiver.json"

i=0
j=0

while wait
do
    sleep 1 &
    i=$((i+1))
    if [[ $i == 15 ]]; then
        i=0
        cp /run/dump1090-fa/aircraft.json "$TARGET/history_$j.json" || true
        j=$((j+1))
        if [[ $j == 120 ]]; then
            j=0
        fi
    fi
    cp /run/dump1090-fa/aircraft.json "$TARGET/aircraft.json" || true
done

Default history is 30 second between points in the track and 1 hour long.
This is 15 second between points, so only 30 min history.

This script is completely untested …

And with some variables and minimal testing:

#!/bin/bash

SOURCE=/run/readsb
TARGET=/tmp/testbla
HIST_INTERVAL=15

cp "$SOURCE/receiver.json" "$TARGET/receiver.json"

i=0
j=0

while wait
do
    sleep 1 &
    i=$((i+1))
    if [[ "$i" == "$HIST_INTERVAL" ]]; then
        i=0
        cp "$SOURCE/aircraft.json" "$TARGET/history_$j.json" || true
        j=$((j+1))
        if [[ $j == 120 ]]; then
            j=0
        fi
    fi
    cp "$SOURCE/aircraft.json" "$TARGET/aircraft.json" || true
done

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.