I am trying to purge data on my devices everyday, it seems to improve the performance a lot
I want to use the following code in a start.sh in one of my services
curl -X POST --header “Content-Type:application/json” “$BALENA_SUPERVISOR_ADDRESS/v2/applications/$BALENA_APP_ID/purge?apikey=$BALENA_SUPERVISOR_API_KEY”
It will go in a endless loop everytime i restart
So i was thinking I could check - if( /data is empty){ dont purge}else{purge}
Where is the user applications data folder mentioned in the supervisor docs
I’ve been thinking about your workflow a bit and I may have a solution.
Since it sounds like you are already using multiple services, what if you added an additional service to your app with a sole purpose of sleeping for 24-hours before running the supervisor purge?
Something like as the entrypoint script:
#!/bin/sh
sleep 24h
curl -X POST --header "Content-Type:application/json" "$BALENA_SUPERVISOR_ADDRESS/v2/applications/$BALENA_APP_ID/purge?apikey=$BALENA_SUPERVISOR_API_KEY"
# all services restart at this point
This way you avoid the restart loop, but after 24-hours the purge command will be run resulting in a restart of all services, including this one.
Another way would be to manually rm -rf all the named volumes from within an additional service, but that would mean the other services would keep running as the data is being removed, which may or may not work for your app.
Let me know if this solution works for you or or if we should go back to the drawing board!
How do I access the Host container from a child service to delete the /mnt/data folder?
You can not access the host’s /mnt/data from a container.
When my colleague said “Another way would be to manually rm -rf all the named volumes from within an additional service”, he meant “mount all of the existing Named Volumes into this service as well and run rm -rf in each one”
Something like: