Open allthesignals opened 7 years ago
This comment suggests they're read from redis! -> https://github.com/CartoDB/CartoDB-SQL-API/blob/14846b254e4841c12afb14cf02a09bf9a4744216/config/environments/production.js.example#L23
Username is extracted from regex here đź‘Ť: https://github.com/CartoDB/CartoDB-SQL-API/blob/14846b254e4841c12afb14cf02a09bf9a4744216/config/environments/production.js.example#L17
Remaining mysteries, some I have emailed to @zingbot:
Which Redis database is the test suite pointing to? Documentation mentions this: “Make sure redis is running and knows about active cartodb user.” What is redis used for in the SQL API? What is an active cartodb user?
- I made some progress on this front - the Redis store is used for configuration variables as well as setting up some of the user configuration (usernames). How should I create a “cartodb user” for development, staging, or production? I know the test suite does that with “cartodb250user”.
- Related issue: https://github.com/codefornl/carto-sql-api-docker/issues/1 Would it be possible to remove the redis dependency? (In other words, do the core features of SQL API depend on redis?)
Carto official seems to use table schemas and associate them with specific Carto users. Do Carto usernames relate to the subdomain for SQL API specifically, and do table schemas in Postgres need to be tied to a specific CartoDB user? Our goal doesn’t include having any user management (only one main user to get it to work). For example: When I run
node app.js test
, I can visit this URL successfully: http://cartodb250user.localhost:8080/api/v2/sql?q=select%20*%20from%20test_geometry_table. I guess my question is how do I create or manage the “cartodb250user” part of the URL?
This shell script can be a way to generate the configuration file with server environment variables: https://github.com/codefornl/carto-sql-api-docker/blob/master/run.sh
Let's use postinstall
in package.json
to trigger the shell script before Heroku kicks off the Procfile: https://docs.npmjs.com/misc/scripts#examples.
Progress! Now to test on Heroku with .env variables configured correctly. One possible issue: if a user deploys without the proper environment variable, it's not clear if setting it in Heroku will kick off the package.json postinstall
, which generates the configuration file. It might need a full rebuild.
^ On that front, according to docs:
prestart, start, poststart: Run by the npm start command.
Can't use those npm hooks because Procfile command needs environment variable
To deploy to Heroku, we need to make the config files pull from the environment.
https://12factor.net/config
Right now, they use templated files: https://github.com/MAPC/CartoDB-SQL-API/blob/master/config/environments/staging.js.example.