Currently:
root.json contains a list of:
'human project name' : 'project.json'
for each rockon
root.json and all project.json files are pulled every update. Failure to pull them all seems to result in an aborted update with no results.
This data seems to be held in memory and not written to the rockons share (or maybe it isnt until its fully downloaded so any timeout aborts the whole process)
- rockon update pulls a meta list from /rockons/root.json
- (as http and gets redirected to https, so fix that and half your web requests)
- root.json has a list of all projects and is parsed
- each project file is then pulled down, one after the other
- (some seem to be pulled as http and redirected to https, again doubling requests)
Suggested:
Store the rockon’s list on the local rockon share. Then the problem just becomes how to update that. Here we have already split the problem (using rockons) into two distinct parts. The rockons code in the web interface uses the local store of rockons, so the problem now is how to update that local list.
Create ‘version 2’ fetch url at: /rockons/v2/
generate /rockons/v2/root.json (as outlined in the new format below) from data in existing /rockons/root.json
generate /rockons/v2/root.sha from sha hash on root.json
The format of /rockons/v2/root.json is now a list of
'human project name' : { url:'project.json', sha:'sha checksum', ...other fields?... }
(which should be easy to script from the existing /rockons/root.json)
- rockon update pulls the root.sha
- if the sha does not match the local copy, pull root.json into local storage
- (if it did match, no need to pull again, just use the local copy)
- walk projects in root.json and pull any project.json’s where local sha doesnt match the sha entry in root.json
- (at this point you know how many downloads you will need to do so you can put up a progress bar)
- delete any local projects not in root.json
- (you now have a complete list of rockon’s in the minumum number of requests)
- (I would also have a local directory for manually added projects which is always added, overriding projects in root.json for easy development)
Positives
- much less webserver load
- loading can be incremental (in that if it times out half way through, then when run again, anything that was sucessfully fetched before timeout will not be fetched again, as it’s sha will match and so it will be considered ‘fetched’ already)
- only changed files (plus root.json) are pulled on changes
- its easy to pull the rockons list from somewhere else (ie, git repo into local directory to simulate an update without needing to use the inbuilt update at all) (or maybe you could share it on an nfs directory and just symlink it into the local rockons share if you have a cluster of rockons)
negatives
- requires reworking of rockon update code and change in file format.
- requires script to generate /rockons/v2/ from /rockons/root.json
Why use root.sha as the first fetch? Well i figured its very small so the size of root.json doesnt matter and it can be fetched in probably 1 packet. You could also include a url in that root.sha to point to somewhere else to fetch the json files from so you would only need high capacity hosting for the root.sha because that would be fetched every update but the json files would only be pulled if there was ever a change. Then you could host the root.sha on google or amazon cloud and it would be speedy.
optional extras
Extend format to add utc time to each entry in root.json so that an update can show the ‘last updated’ entry for a project.
If you stored info on the date you installed a rockon, you could easily identify ones that have been updated then. (I dont know, i havnt been able to get rockons working at all so i dont know what a successful page of them looks like, haha).
You could even have version1 and version2 both living in the same tree. Rather than root.json, version2 would use root.v2.json and root.v2.sha (or something) and all the other files would be the same.
github?
As an after throught, why not just offload it all onto github and have rockons update just do a git pull from the github repo? why reintent this wheel? Pull it from github into a directory in /mnt2/whatever-rocksons-share/plugin-data and have the rockons page work from there?
You dont even need git, as you can fetch the raw pages from github via http so you could move it off your webserver completely.