persistent state best practice?
roger peppe
roger.peppe at canonical.com
Sun Aug 2 14:46:34 UTC 2015
I've got a Snappy app that stores some state in a local
file. I see that it has read/write access to
/var/lib/apps/$appname.sideload/$version and
read-only access to /var/lib/apps/$appname.sideload/$otherversions.
I see that $SNAP_APP_DATA_PATH points to the
writable directory, but I don't see any documentation
for that environment variable (or any of the SNAP_APP environment
variables). Is this something I can rely on? I
see that $SNAPP_APP* is also possible - is one of those
forms deprecated?
What is the best thing to do with regard to maintaining
consistent state? My current thought is something like:
- if $SNAP_APP_DATA_PATH directory is not empty,
use it.
- otherwise search through $SNAP_APP_DATA_PATH/../*
looking for the database file with the most recent
modification time; then copy it to $SNAP_APP_DATA_PATH
and start using it.
Does that seem like a reasonable heuristic?
It seems a pity that I need to duplicate the data space
when upgrading, particularly if it might grow quite large.
This will work for upgrading versions, but not for downgrading.
I am concerned that it relies on any services started
by the old version being stopped before the new one is
started, but that's not always been the case for me.
(I had to manually stop an old service to allow the
new one to start on at least one occasion).
Your thoughts would be appreciated.
cheers,
rog.
More information about the snappy-devel
mailing list