Refactor account code creation/population to allow codes to be created independently of the deployment
In the deployment environment, it is not possible (due to our choice of an in-process, single-connection database, LevelDB), to run the current account generation script while the app itself is running.
It is also more flexible to separate the app and the account code creation so that the account code creation script can exist independently.
How it should work
-
On any machine, someone runs the account code script and generates the codes, which are saved to a JSON file in a directory with an index suffix: e.g., codes-0.json. Successive runs of the script on the same machine cause the counter to increase. Old codes are not deleted. (e.g., codes-1.json, codes-2.json, etc.)
-
The codes directory is copied to the app (e.g., to ~/.hallo.gent/codes)
-
On startup, the app loads in all the files in that directory and checks to see if there are any new files that are not in its database. If there are, it populates the database with the new codes and then continues the rest of the startup process.