Use Redis as caching mechanism
parent
7644454066
commit
3adbfc824f
4
Gemfile
4
Gemfile
|
@ -3,7 +3,7 @@ ruby "2.5.1"
|
||||||
|
|
||||||
gem "active_model_serializers"
|
gem "active_model_serializers"
|
||||||
gem "bunny"
|
gem "bunny"
|
||||||
gem "delayed_job_active_record"
|
gem "delayed_job_active_record" # TODO: Get off of SQL backed jobs. Use Redis
|
||||||
gem "delayed_job"
|
gem "delayed_job"
|
||||||
gem "devise"
|
gem "devise"
|
||||||
gem "discard"
|
gem "discard"
|
||||||
|
@ -31,7 +31,7 @@ gem "webpack-rails"
|
||||||
# Still working out the bugs. - RC 5 Jul 18
|
# Still working out the bugs. - RC 5 Jul 18
|
||||||
gem "rabbitmq_http_api_client"
|
gem "rabbitmq_http_api_client"
|
||||||
gem "zero_downtime_migrations"
|
gem "zero_downtime_migrations"
|
||||||
# gem "digest-murmurhash"
|
gem "redis", "~> 4.0"
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem "thin"
|
gem "thin"
|
||||||
|
|
|
@ -262,6 +262,7 @@ GEM
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.19.0, < 2.0)
|
thor (>= 0.19.0, < 2.0)
|
||||||
rake (12.3.1)
|
rake (12.3.1)
|
||||||
|
redis (4.0.2)
|
||||||
representable (3.0.4)
|
representable (3.0.4)
|
||||||
declarative (< 0.1.0)
|
declarative (< 0.1.0)
|
||||||
declarative-option (< 0.2.0)
|
declarative-option (< 0.2.0)
|
||||||
|
@ -389,6 +390,7 @@ DEPENDENCIES
|
||||||
rails
|
rails
|
||||||
rails-erd
|
rails-erd
|
||||||
rails_12factor
|
rails_12factor
|
||||||
|
redis (~> 4.0)
|
||||||
request_store
|
request_store
|
||||||
rollbar
|
rollbar
|
||||||
rspec
|
rspec
|
||||||
|
@ -409,4 +411,4 @@ RUBY VERSION
|
||||||
ruby 2.5.1p57
|
ruby 2.5.1p57
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.16.2
|
1.16.5
|
||||||
|
|
|
@ -25,6 +25,8 @@ class RmqConfigWriter
|
||||||
"using 3rd party MQTT hosting, please set this value and "\
|
"using 3rd party MQTT hosting, please set this value and "\
|
||||||
"re-build the server image."
|
"re-build the server image."
|
||||||
TEMPLATE = <<~END
|
TEMPLATE = <<~END
|
||||||
|
# THIS FILE WAS GENERATED BY THE `RmqConfigWriter` CLASS IN THE RAILS APP
|
||||||
|
# == DO NOT ATTEMPT TO MODIFY MANUALLY - IT WILL BE OVERWRITTEN ===
|
||||||
auth_backends.1 = cache
|
auth_backends.1 = cache
|
||||||
auth_cache.cache_ttl = 600000
|
auth_cache.cache_ttl = 600000
|
||||||
auth_cache.cached_backend = http
|
auth_cache.cached_backend = http
|
||||||
|
@ -41,7 +43,6 @@ class RmqConfigWriter
|
||||||
END
|
END
|
||||||
|
|
||||||
def self.do_render
|
def self.do_render
|
||||||
puts "Writing RMQ Config ================================================="
|
|
||||||
raise BAD_PASSWORD if ADMIN_PASSWORD.length < 5
|
raise BAD_PASSWORD if ADMIN_PASSWORD.length < 5
|
||||||
FileUtils.mkdir_p CONFIG_PATH
|
FileUtils.mkdir_p CONFIG_PATH
|
||||||
File.open(CONFIG_OUTPUT, "w+") { |f| f.write(TEMPLATE % CFG_DATA) }
|
File.open(CONFIG_OUTPUT, "w+") { |f| f.write(TEMPLATE % CFG_DATA) }
|
||||||
|
|
|
@ -9,10 +9,9 @@ Bundler.require(:default, Rails.env)
|
||||||
module FarmBot
|
module FarmBot
|
||||||
class Application < Rails::Application
|
class Application < Rails::Application
|
||||||
Delayed::Worker.max_attempts = 4
|
Delayed::Worker.max_attempts = 4
|
||||||
# config.after_initialize do
|
REDIS_ENV_KEY = ENV.fetch("WHERE_IS_REDIS_URL", "REDIS_URL")
|
||||||
# Bullet.enable = true
|
REDIS_URL = ENV.fetch(REDIS_ENV_KEY, "redis://redis:6379/0")
|
||||||
# Bullet.console = true
|
config.cache_store = :redis_cache_store, { url: REDIS_URL }
|
||||||
# end
|
|
||||||
config.active_record.schema_format = :sql
|
config.active_record.schema_format = :sql
|
||||||
config.active_job.queue_adapter = :delayed_job
|
config.active_job.queue_adapter = :delayed_job
|
||||||
config.action_dispatch.perform_deep_munge = false
|
config.action_dispatch.perform_deep_munge = false
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
FarmBot::Application.configure do
|
FarmBot::Application.configure do
|
||||||
|
|
||||||
config
|
config
|
||||||
.action_mailer
|
.action_mailer
|
||||||
.default_url_options = { host: ENV.fetch("API_HOST", "my.farmbot.io") }
|
.default_url_options = { host: ENV.fetch("API_HOST", "my.farmbot.io") }
|
||||||
config.active_support.deprecation = :notify
|
config.active_support.deprecation = :notify
|
||||||
config.cache_classes = true
|
config.cache_classes = true
|
||||||
config.cache_store = :null_store
|
|
||||||
config.consider_all_requests_local = false
|
config.consider_all_requests_local = false
|
||||||
config.eager_load = true
|
config.eager_load = true
|
||||||
config.force_ssl = true if ENV["FORCE_SSL"]
|
config.force_ssl = true if ENV["FORCE_SSL"]
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Some services do not use ENV vars as the configuration mechanism (I wish they
|
||||||
|
# would). To simplify setup for self-hosters, we perform magic in the background
|
||||||
|
# that converts ENV vars into config files. - RC
|
||||||
|
RmqConfigWriter.render
|
|
@ -1,2 +0,0 @@
|
||||||
|
|
||||||
RmqConfigWriter.render
|
|
|
@ -1,6 +1,6 @@
|
||||||
version: '3.4'
|
version: '3.4'
|
||||||
x-db_user: &db_user
|
x-db_user: &db_user
|
||||||
depends_on: ["db"]
|
depends_on: ["db", "redis"]
|
||||||
x-rails: &rails
|
x-rails: &rails
|
||||||
image: farmbot_web
|
image: farmbot_web
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
@ -9,8 +9,10 @@ x-rails: &rails
|
||||||
- ./docker_volumes/bundle_cache:/bundle
|
- ./docker_volumes/bundle_cache:/bundle
|
||||||
services:
|
services:
|
||||||
redis:
|
redis:
|
||||||
image: redis:4.0.11
|
image: redis
|
||||||
environment: ["REDIS_PASS=mypass"]
|
volumes:
|
||||||
|
- ./docker_volumes/redis/data:/data
|
||||||
|
- ./docker_volumes/redis/conf:/usr/local/etc/redis
|
||||||
ports: ["6379:6379"]
|
ports: ["6379:6379"]
|
||||||
db: # ====================
|
db: # ====================
|
||||||
image: postgres
|
image: postgres
|
||||||
|
|
|
@ -63,7 +63,14 @@ FORCE_SSL=Remove this if not using HTTPS://
|
||||||
# If running a FarmBot setup for personal use or none of the above apply, you
|
# If running a FarmBot setup for personal use or none of the above apply, you
|
||||||
# can safely delete the rest of this file.
|
# can safely delete the rest of this file.
|
||||||
|
|
||||||
|
# Only relevant if you use Heroku or pay a 3rd party vendor for Redis hosting.
|
||||||
|
# Most users can delete this.
|
||||||
|
# If your Heroku Redis vendor uses a custom `REDIS_URL` ENV var such as
|
||||||
|
# `REDISTOGO_URL`, set the value here. If you delete this line, the app will
|
||||||
|
# default to `REDIS_URL`.
|
||||||
|
WHERE_IS_REDIS_URL=REDISTOGO_URL # Just an example. Change or delete.
|
||||||
|
# Delete this if you don't use 3rd party Redis hosting. See WHERE_IS_REDIS_URL
|
||||||
|
REDIS_URL=redis://redis:6379/0
|
||||||
|
|
||||||
# For email delivery. Who is your email host?
|
# For email delivery. Who is your email host?
|
||||||
SMTP_HOST=smtp.sendgrid.net
|
SMTP_HOST=smtp.sendgrid.net
|
||||||
|
|
Loading…
Reference in New Issue