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 "bunny"
|
||||
gem "delayed_job_active_record"
|
||||
gem "delayed_job_active_record" # TODO: Get off of SQL backed jobs. Use Redis
|
||||
gem "delayed_job"
|
||||
gem "devise"
|
||||
gem "discard"
|
||||
|
@ -31,7 +31,7 @@ gem "webpack-rails"
|
|||
# Still working out the bugs. - RC 5 Jul 18
|
||||
gem "rabbitmq_http_api_client"
|
||||
gem "zero_downtime_migrations"
|
||||
# gem "digest-murmurhash"
|
||||
gem "redis", "~> 4.0"
|
||||
|
||||
group :development, :test do
|
||||
gem "thin"
|
||||
|
|
|
@ -262,6 +262,7 @@ GEM
|
|||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rake (12.3.1)
|
||||
redis (4.0.2)
|
||||
representable (3.0.4)
|
||||
declarative (< 0.1.0)
|
||||
declarative-option (< 0.2.0)
|
||||
|
@ -389,6 +390,7 @@ DEPENDENCIES
|
|||
rails
|
||||
rails-erd
|
||||
rails_12factor
|
||||
redis (~> 4.0)
|
||||
request_store
|
||||
rollbar
|
||||
rspec
|
||||
|
@ -409,4 +411,4 @@ RUBY VERSION
|
|||
ruby 2.5.1p57
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.2
|
||||
1.16.5
|
||||
|
|
|
@ -25,6 +25,8 @@ class RmqConfigWriter
|
|||
"using 3rd party MQTT hosting, please set this value and "\
|
||||
"re-build the server image."
|
||||
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_cache.cache_ttl = 600000
|
||||
auth_cache.cached_backend = http
|
||||
|
@ -41,7 +43,6 @@ class RmqConfigWriter
|
|||
END
|
||||
|
||||
def self.do_render
|
||||
puts "Writing RMQ Config ================================================="
|
||||
raise BAD_PASSWORD if ADMIN_PASSWORD.length < 5
|
||||
FileUtils.mkdir_p CONFIG_PATH
|
||||
File.open(CONFIG_OUTPUT, "w+") { |f| f.write(TEMPLATE % CFG_DATA) }
|
||||
|
|
|
@ -9,12 +9,11 @@ Bundler.require(:default, Rails.env)
|
|||
module FarmBot
|
||||
class Application < Rails::Application
|
||||
Delayed::Worker.max_attempts = 4
|
||||
# config.after_initialize do
|
||||
# Bullet.enable = true
|
||||
# Bullet.console = true
|
||||
# end
|
||||
REDIS_ENV_KEY = ENV.fetch("WHERE_IS_REDIS_URL", "REDIS_URL")
|
||||
REDIS_URL = ENV.fetch(REDIS_ENV_KEY, "redis://redis:6379/0")
|
||||
config.cache_store = :redis_cache_store, { url: REDIS_URL }
|
||||
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
|
||||
I18n.enforce_available_locales = false
|
||||
LOCAL_API_HOST = ENV["API_HOST"] || "localhost"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
FarmBot::Application.configure do
|
||||
|
||||
config
|
||||
.action_mailer
|
||||
.default_url_options = { host: ENV.fetch("API_HOST", "my.farmbot.io") }
|
||||
config.active_support.deprecation = :notify
|
||||
config.cache_classes = true
|
||||
config.cache_store = :null_store
|
||||
config.consider_all_requests_local = false
|
||||
config.eager_load = true
|
||||
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'
|
||||
x-db_user: &db_user
|
||||
depends_on: ["db"]
|
||||
depends_on: ["db", "redis"]
|
||||
x-rails: &rails
|
||||
image: farmbot_web
|
||||
env_file: .env
|
||||
|
@ -9,9 +9,11 @@ x-rails: &rails
|
|||
- ./docker_volumes/bundle_cache:/bundle
|
||||
services:
|
||||
redis:
|
||||
image: redis:4.0.11
|
||||
environment: ["REDIS_PASS=mypass"]
|
||||
ports: ["6379:6379"]
|
||||
image: redis
|
||||
volumes:
|
||||
- ./docker_volumes/redis/data:/data
|
||||
- ./docker_volumes/redis/conf:/usr/local/etc/redis
|
||||
ports: ["6379:6379"]
|
||||
db: # ====================
|
||||
image: postgres
|
||||
volumes: ["./docker_volumes/db:/var/lib/postgresql/data"]
|
||||
|
|
|
@ -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
|
||||
# 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?
|
||||
SMTP_HOST=smtp.sendgrid.net
|
||||
|
|
Loading…
Reference in New Issue