2016-07-11 16:47:07 +08:00
|
|
|
# CARTO Data Services API
|
|
|
|
The CARTO Data Services SQL API
|
2016-01-25 23:22:00 +08:00
|
|
|
|
|
|
|
### Deploy instructions
|
2016-02-25 21:30:19 +08:00
|
|
|
Steps to deploy a new Data Services API version :
|
2016-01-25 23:22:00 +08:00
|
|
|
|
2016-02-09 17:23:25 +08:00
|
|
|
- Deploy new version of dataservices API to all servers
|
|
|
|
- Update the server user using: ALTER EXTENSION cdb_dataservices_server UPDATE TO '<CURRENT_VERSION>';
|
2016-01-25 23:22:00 +08:00
|
|
|
- Update the python dependencies if needed: **cartodb_geocoder** and **heremaps**
|
|
|
|
- Add the needed config in the `cdb_conf` table:
|
|
|
|
- `redis_metadata_config` and `redis_metrics_conf`
|
2016-02-09 17:23:25 +08:00
|
|
|
- `{"sentinel_host": "localhost", "sentinel_port": 26379, "sentinel_master_id": "mymaster", "timeout": 0.1, "redis_db": 5}`
|
2016-01-25 23:22:00 +08:00
|
|
|
- `heremaps_conf`
|
|
|
|
- `{"app_id": "APP_ID", "app_code": "APP_CODE"}`
|
|
|
|
- Deploy the client to all the servers with the new version
|
2016-02-09 17:23:25 +08:00
|
|
|
- Deploy the editor with the new dataservices api version changed (https://github.com/CartoDB/cartodb/blob/master/app/models/user/db_service.rb#L18)
|
2016-01-25 23:22:00 +08:00
|
|
|
- Execute the rails task to update first the CartoDB team organizaton to test in production
|
|
|
|
- `RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_organizations['team']`
|
|
|
|
- Check if all works perfectly for our team. If so, execute the rake tasks to update all the users and organizations:
|
|
|
|
- `RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_organizations['', true]`
|
|
|
|
- `RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_non_org_users['', true]`
|
2016-02-09 17:23:25 +08:00
|
|
|
- Freeze the generated SQL file for the version. Eg. cdb_dataservices_server--0.0.1.sql
|
2016-02-24 18:54:55 +08:00
|
|
|
|
|
|
|
### Local install instructions
|
|
|
|
|
2016-03-31 21:02:19 +08:00
|
|
|
- install data services geocoder extension
|
2016-02-24 18:54:55 +08:00
|
|
|
|
|
|
|
```
|
|
|
|
git clone git@github.com:CartoDB/data-services.git
|
2016-03-31 21:02:19 +08:00
|
|
|
cd data-services/geocoder/extension
|
2016-02-24 18:54:55 +08:00
|
|
|
sudo make install
|
|
|
|
```
|
2016-04-27 21:42:06 +08:00
|
|
|
|
|
|
|
- install observatory extension
|
|
|
|
|
|
|
|
```
|
|
|
|
git clone git@github.com:CartoDB/observatory-extension.git
|
|
|
|
cd observatory
|
|
|
|
sudo make install
|
|
|
|
```
|
2016-02-24 18:54:55 +08:00
|
|
|
|
|
|
|
- install server and client extensions
|
|
|
|
|
|
|
|
```
|
|
|
|
cd client && sudo make install
|
2016-03-31 21:02:19 +08:00
|
|
|
cd server/extension && sudo make install
|
2016-02-24 18:54:55 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
- install python library
|
|
|
|
|
|
|
|
```
|
2016-06-24 16:13:25 +08:00
|
|
|
cd server/lib/python/cartodb_services && sudo pip install --upgrade .
|
2016-02-24 18:54:55 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
- install extensions in user database
|
|
|
|
|
|
|
|
```
|
|
|
|
create extension cdb_geocoder;
|
|
|
|
create extension plproxy;
|
2016-04-27 21:42:06 +08:00
|
|
|
create extension observatory;
|
2016-02-24 18:54:55 +08:00
|
|
|
create extension cdb_dataservices_server;
|
|
|
|
create extension cdb_dataservices_client;
|
|
|
|
```
|
|
|
|
|
2016-06-24 17:29:21 +08:00
|
|
|
- add configuration for different services in server database
|
2016-02-24 18:54:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
```
|
2016-03-31 22:01:22 +08:00
|
|
|
# If sentinel is used:
|
|
|
|
SELECT CDB_Conf_SetConf('redis_metadata_config', '{"sentinel_host": "localhost", "sentinel_port": 26379, "sentinel_master_id": "mymaster", "timeout": 0.1, "redis_db": 5}');
|
2016-06-24 17:29:21 +08:00
|
|
|
SELECT CDB_Conf_SetConf('redis_metrics_config', '{"sentinel_host": "localhost", "sentinel_port": 26379, "sentinel_master_id": "mymaster", "timeout": 0.1, "redis_db": 5}');
|
2016-03-31 22:11:03 +08:00
|
|
|
|
2016-03-31 22:01:22 +08:00
|
|
|
# If sentinel is not used
|
2016-06-24 17:29:21 +08:00
|
|
|
SELECT CDB_Conf_SetConf('redis_metadata_config', '{"redis_host": "localhost", "redis_port": 6379, "sentinel_master_id": "", "timeout": 0.1, "redis_db": 5}');
|
2016-03-31 22:11:03 +08:00
|
|
|
SELECT CDB_Conf_SetConf('redis_metrics_config', '{"redis_host": "localhost", "redis_port": 6379, "sentinel_master_id": "", "timeout": 0.1, "redis_db": 5}');
|
2016-03-31 22:01:22 +08:00
|
|
|
|
2016-04-27 21:38:48 +08:00
|
|
|
SELECT CDB_Conf_SetConf('heremaps_conf', '{"geocoder": {"app_id": "here_geocoder_app_id", "app_code": "here_geocoder_app_code", "geocoder_cost_per_hit": "1"}, "isolines" : {"app_id": "here_isolines_app_id", "app_code": "here_geocoder_app_code"}}');
|
2016-03-31 22:01:22 +08:00
|
|
|
SELECT CDB_Conf_SetConf('user_config', '{"is_organization": false, "entity_name": "<YOUR_USERNAME>"}')
|
2016-04-27 21:38:48 +08:00
|
|
|
SELECT CDB_Conf_SetConf('mapzen_conf', '{"routing": {"api_key": "valhalla_app_key", "monthly_quota": 999999}, "geocoder": {"api_key": "search_app_key", "monthly_quota": 999999}}');
|
2016-06-28 18:06:13 +08:00
|
|
|
SELECT CDB_Conf_SetConf('logger_conf', '{"geocoder_log_path": "/tmp/geocodings.log"}')
|
2016-05-23 21:35:35 +08:00
|
|
|
SELECT CDB_Conf_SetConf('data_observatory_conf', '{"connection": {"whitelist": [], "production": "host=localhost port=5432 dbname=dataservices_db user=geocoder_api", "staging": "host=localhost port=5432 dbname=dataservices_db user=geocoder_api"}}')
|
2016-02-24 18:54:55 +08:00
|
|
|
```
|
|
|
|
|
2016-06-24 17:29:21 +08:00
|
|
|
- configure the user DB:
|
2016-02-24 18:54:55 +08:00
|
|
|
|
2016-06-24 17:29:21 +08:00
|
|
|
```sql
|
|
|
|
-- Point to the dataservices server DB (you can use a specific database for the server or your same user's):
|
|
|
|
SELECT CDB_Conf_SetConf('geocoder_server_config', '{ "connection_str": "host=localhost port=5432 dbname=<SERVER_DB_NAME> user=postgres"}');
|
|
|
|
|
|
|
|
SELECT CDB_Conf_SetConf('user_config', '{"is_organization": false, "entity_name": "<YOUR_USERNAME>"}');
|
2016-02-24 18:54:55 +08:00
|
|
|
```
|
2016-02-24 19:13:57 +08:00
|
|
|
|
2016-03-31 21:02:19 +08:00
|
|
|
- configure the search path in order to be able to execute the functions without using the schema:
|
2016-02-24 19:13:57 +08:00
|
|
|
|
|
|
|
```
|
2016-03-31 22:01:22 +08:00
|
|
|
ALTER ROLE "<USER_ROLE>" SET search_path="$user", public, cartodb, cdb_dataservices_client;
|
2016-02-24 19:13:57 +08:00
|
|
|
```
|