Why a JSON file?
The Janitor’s servers currently store all their data in a local ./db.json
file, using a tiny ad-hoc db.js module to read and write this file.
When a Janitor server starts running, the db.json
datastore is loaded into RAM, and only written back to disk occasionally in order to prevent data loss in case of a server crash.
This is by no means an industry-standard database, and we should upgrade to something more robust and scalable in the future (if you know about these things, please post your suggestions here!). It was the simplest system we could implement to efficiently store all of our data with very little complexity.
What’s in there?
A db.json
file usually contains the following entries:
-
"hostname"
:"localhost"
(see explanation) -
"ports"
: (see explanations)-
"http"
:1080
-
"https"
:1443
-
-
"security"
: (see pull request and explanations)-
"forceHttp"
: false -
"forceInsecure"
: false
-
-
"mailer"
: (see email-login’s “mailer” specification)-
"block"
:false
-
"from"
:""
-
"host"
:""
-
"auth"
:-
"user"
:""
-
"pass"
""
-
-
-
"hosts"
:-
"localhost"
: (see host creation code)-
"properties"
:-
"port"
:"2376"
-
"ca"
:""
-
"crt"
:""
-
"key"
:""
-
-
"oauth2client"
: (automatically generated for all new hosts)-
"id"
:""
-
"secret"
:""
-
-
-
-
"projects"
:-
"firefox"
:{}
(see project creation code) -
"chromium"
:{}
…
-
-
"users"
:-
"user@example.com"
: (see user creation code)-
"emails"
:[]
-
"profile"
:-
"name"
:"Example User"
-
-
"keys"
:{}
-
"machines"
:-
"firefox"
:[]
(see machine creation code) -
"chromium"
:[]
…
-
-
-
-
"waitlist"
:[]
-
"admins"
:-
"admin@example.com"
:true
-
Examples
- Minimal db.json for Janitor developers, used in development containers on Janitor
- Redacted db.json from janitor.technology, a more realistic example with an admin user, 1 project, 2 containers and 3 docker hosts