-
Notifications
You must be signed in to change notification settings - Fork 166
Description
We need some preliminary, rudimentary log upload support. This will be superseded by something more intelligent later.
Currently the DataFlash logs are written to ~apsync/dflogger/dataflash.
We need to get those logs off the companion computer and onto a server somewhere (heretoforth known as "the cloud")
- We need a route from the companion computer to the cloud
- we need to handle the case where logs are deleted from the CC
- we need to handle the CC being rebooted
Proposal:
- add to web interface:
- ability to define a "to" server (by hostname or IP address) as a text input box in the web interface on port 8000 (CLOUDSYNC_ADDRESS)
- add ability to paste in the contents of an
identity_fileto be used when trying to upload logs - add ability to specify a username for synchronising logs up (CLOUDSYNC_USER)
- add a field to contain a unique identifier for this vehicle
- modify a daemon on the system (MAVProxy?) to run a job once/minute
- if there is no route to the cloud then exit
- if the vehicle is armed then exit; if the vehicle ever becomes armed then kill the syncing process
- if the vehicle becomes
- generate a timestamped destination directory
- e.g.
dataflash-${VEHICLE_UNIQUE_ID}-$(date '+%Y%m%d%H%M%S)` (CLOUDSYNC_DIR) - for each file in the dataflash directory, stat it for modifcations over, say, 15 seconds. If not changed, attempt to sync it to cloud
- invoke rsync, something like this:
rsync -aHz $FILEPATH ${CLOUDSYNC_USER}@${CLOUDSYNC_ADDRESS}:$CLOUDSYNC_DIR
- if the rsync completes successfully, move the file on APSync to a local
$HOME/dflogger/dataflash-archive/$CLOUDSYNC_DIRdirectory
Doing the files individually has the advantage that we will avoid pushing the same file up multiple times into differently-timestamped directories should the rsync transfer be interrupted by e.g. the CC machine being rebooted. The lack of --partial on the receiver end should mean that we don't end up with partial logs on the server, at the expense of transferring the same data multiple times.
Note that simply running rsync directly on the $HOME/dflogger/dataflash directory will seldom succeed as a file is constantly being written in that directory.