Enabled sync tables for all users + periodically trigger sync tables task

Refs #11
This commit is contained in:
Stefan Verhoeven 2017-08-01 22:07:30 +02:00
parent 6b0e3c6e2f
commit 5218b9940e
5 changed files with 22 additions and 1 deletions

View File

@ -221,6 +221,7 @@ ADD ./config/varnish.vcl /etc/varnish.vcl
ADD ./geocoder.sh /cartodb/script/geocoder.sh ADD ./geocoder.sh /cartodb/script/geocoder.sh
ADD ./geocoder_server.sql /cartodb/script/geocoder_server.sql ADD ./geocoder_server.sql /cartodb/script/geocoder_server.sql
ADD ./fill_geocoder.sh /cartodb/script/fill_geocoder.sh ADD ./fill_geocoder.sh /cartodb/script/fill_geocoder.sh
ADD ./sync_tables_trigger.sh /cartodb/script/sync_tables_trigger.sh
ENV PATH /usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ENV PATH /usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN mkdir -p /cartodb/log && touch /cartodb/log/users_modifications && \ RUN mkdir -p /cartodb/log && touch /cartodb/log/users_modifications && \
/opt/varnish/sbin/varnishd -a :6081 -T localhost:6082 -s malloc,256m -f /etc/varnish.vcl && \ /opt/varnish/sbin/varnishd -a :6081 -T localhost:6082 -s malloc,256m -f /etc/varnish.vcl && \
@ -228,12 +229,17 @@ RUN mkdir -p /cartodb/log && touch /cartodb/log/users_modifications && \
bash -l -c "cd /cartodb && bash script/create_dev_user && \ bash -l -c "cd /cartodb && bash script/create_dev_user && \
bash script/setup_organization.sh && bash script/geocoder.sh" && \ bash script/setup_organization.sh && bash script/geocoder.sh" && \
service postgresql stop && service redis-server stop && \ service postgresql stop && service redis-server stop && \
chmod +x /cartodb/script/fill_geocoder.sh chmod +x /cartodb/script/fill_geocoder.sh && \
chmod +x /cartodb/script/sync_tables_trigger.sh
EXPOSE 80 EXPOSE 80
ENV GDAL_DATA /usr/share/gdal/1.11 ENV GDAL_DATA /usr/share/gdal/1.11
# Number of seconds between a sync tables task is run
# Default interval is an hour, use `docker run -e SYNC_TABLES_INTERVAL=60 ...` to change it
ENV SYNC_TABLES_INTERVAL 3600
ADD ./startup.sh /opt/startup.sh ADD ./startup.sh /opt/startup.sh
CMD ["/bin/bash", "/opt/startup.sh"] CMD ["/bin/bash", "/opt/startup.sh"]

View File

@ -33,3 +33,6 @@ rake cartodb:db:set_user_account_type["${SUBDOMAIN}",'[DEDICATED]']
# Set dataservices server # Set dataservices server
rake cartodb:db:configure_geocoder_extension_for_non_org_users[$SUBDOMAIN] rake cartodb:db:configure_geocoder_extension_for_non_org_users[$SUBDOMAIN]
# Enable sync tables
echo "UPDATE users SET sync_tables_enabled=true WHERE username='${SUBDOMAIN}'" | psql -U postgres -t carto_db_development

View File

@ -8,3 +8,6 @@ rake cartodb:db:set_unlimited_table_quota["${USERNAME}"]
rake cartodb:db:create_new_organization_with_owner ORGANIZATION_NAME="${ORGANIZATION_NAME}" USERNAME="${USERNAME}" ORGANIZATION_SEATS=100 ORGANIZATION_QUOTA=102400 ORGANIZATION_DISPLAY_NAME="${ORGANIZATION_NAME}" rake cartodb:db:create_new_organization_with_owner ORGANIZATION_NAME="${ORGANIZATION_NAME}" USERNAME="${USERNAME}" ORGANIZATION_SEATS=100 ORGANIZATION_QUOTA=102400 ORGANIZATION_DISPLAY_NAME="${ORGANIZATION_NAME}"
rake cartodb:db:set_organization_quota[$ORGANIZATION_NAME,5000] rake cartodb:db:set_organization_quota[$ORGANIZATION_NAME,5000]
rake cartodb:db:configure_geocoder_extension_for_organizations[$ORGANIZATION_NAME] rake cartodb:db:configure_geocoder_extension_for_organizations[$ORGANIZATION_NAME]
# Enable sync tables
echo "UPDATE users SET sync_tables_enabled=true WHERE username='${USERNAME}'" | psql -U postgres -t carto_db_development

View File

@ -17,4 +17,5 @@ cd /cartodb
source /usr/local/rvm/scripts/rvm source /usr/local/rvm/scripts/rvm
bundle exec script/restore_redis bundle exec script/restore_redis
bundle exec script/resque > resque.log 2>&1 & bundle exec script/resque > resque.log 2>&1 &
script/sync_tables_trigger.sh &
bundle exec thin start --threaded -p 3000 --threadpool-size 5 bundle exec thin start --threaded -p 3000 --threadpool-size 5

8
sync_tables_trigger.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
while :
do
sleep $SYNC_TABLES_INTERVAL
cd /cartodb
bundle exec rake cartodb:sync_tables[true]
done