diff --git a/Gemfile b/Gemfile index b04181d24..66878a992 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,6 @@ gem 'dotenv-rails', :require => "dotenv/rails-now" gem "rails", "~> 5.2" gem "pg" -gem "dalli", :platforms => :ruby gem "delayed_job" gem "delayed_job_active_record" gem "simple_form" diff --git a/Gemfile.lock b/Gemfile.lock index fc9af36fa..9058bebeb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -118,7 +118,6 @@ GEM safe_yaml (~> 1.0.0) crass (1.0.4) daemons (1.3.1) - dalli (2.7.10) delayed_job (4.1.7) activesupport (>= 3.0, < 5.3) delayed_job_active_record (4.1.3) @@ -458,7 +457,6 @@ DEPENDENCIES capistrano3-unicorn cityhash daemons - dalli delayed_job delayed_job_active_record diff-lcs diff --git a/INSTALL.debian b/INSTALL.debian index 71d43ac91..23340b386 100644 --- a/INSTALL.debian +++ b/INSTALL.debian @@ -48,7 +48,7 @@ fi apt-get update apt-get -y install apt-transport-https apt-get -y install zlib1g-dev libglib2.0-dev -apt-get -y install $LIBSSL_DEV_PKG build-essential automake libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel memcached libmemcached-dev git curl libcurl4-openssl-dev sendmail-bin sendmail nginx ssh coreutils ffmpeg mkvtoolnix +apt-get -y install $LIBSSL_DEV_PKG build-essential automake libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel redis git curl libcurl4-openssl-dev sendmail-bin sendmail nginx ssh coreutils ffmpeg mkvtoolnix apt-get -y install libpq-dev postgresql-client apt-get -y install liblcms2-dev $LIBJPEG_TURBO_DEV_PKG libexpat1-dev libgif-dev libpng-dev libexif-dev diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index 75987077b..026ed3dfe 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -129,11 +129,6 @@ module Danbooru 300 end - # List of memcached servers - def memcached_servers - %w(127.0.0.1:11211) - end - # After a post receives this many comments, new comments will no longer bump the post in comment/index. def comment_threshold 40 @@ -786,6 +781,7 @@ module Danbooru end def redis_url + "redis://localhost:6379" end end diff --git a/config/docker/compose.yml b/config/docker/compose.yml index 7c9a36414..ca82669a7 100644 --- a/config/docker/compose.yml +++ b/config/docker/compose.yml @@ -10,11 +10,6 @@ services: image: redis:latest ports: - "6379:6379" - memcached: - image: memcached:alpine - ports: - - "11211:11211" - command: memcached archives: image: r888888888/archives command: sleep 1d @@ -39,7 +34,6 @@ services: - RO_DATABASE_URL - DEBUG - ARCHIVE_DATABASE_URL - - DANBOORU_MEMCACHED_SERVERS - DANBOORU_AWS_SQS_ARCHIVE_URL - DANBOORU_PIXIV_LOGIN - DANBOORU_PIXIV_PASSWORD @@ -65,6 +59,5 @@ services: - "3000:3000" depends_on: - db - - memcached - archives - - redis \ No newline at end of file + - redis diff --git a/config/initializers/cache_store.rb b/config/initializers/cache_store.rb new file mode 100644 index 000000000..4ee74de3b --- /dev/null +++ b/config/initializers/cache_store.rb @@ -0,0 +1,26 @@ +Rails.application.configure do + if Rails.env.test? + cache_config = [:memory_store, { size: 32.megabytes }] + else + cache_config = [ + :redis_cache_store, + { + url: Danbooru.config.redis_url, + namespace: nil, + connect_timeout: 30, # default: 20 seconds + write_timeout: 0.2, # default: 1 second + read_timeout: 0.2, # default: 1 second + reconnect_attempts: 0, # default: 0 + error_handler: ->(method:, returning:, exception:) { + DanbooruLogger.log(exception, method: method, returning: returning) + } + } + ] + end + + cache_store = ActiveSupport::Cache.lookup_store(cache_config) + + config.cache_store = cache_store + config.action_controller.cache_store = cache_store + Rails.cache = cache_store +end diff --git a/config/initializers/z_dalli.rb b/config/initializers/z_dalli.rb deleted file mode 100644 index aea73d4a5..000000000 --- a/config/initializers/z_dalli.rb +++ /dev/null @@ -1,28 +0,0 @@ -Rails.application.configure do - begin - if Rails.env.test? - config.cache_store = :memory_store, { size: 32.megabytes } - config.action_controller.cache_store = :memory_store, { size: 32.megabytes } - Rails.cache = ActiveSupport::Cache.lookup_store(Rails.application.config.cache_store) - else - config.cache_store = :dalli_store, Danbooru.config.memcached_servers, { namespace: Danbooru.config.safe_app_name } - config.action_controller.cache_store = :dalli_store, Danbooru.config.memcached_servers, { namespace: Danbooru.config.safe_app_name } - Rails.cache = ActiveSupport::Cache.lookup_store(Rails.application.config.cache_store) - - Rails.cache.dalli.alive! - end - rescue Dalli::RingError => e - puts "-" * 40 - puts "WARNING! MEMCACHE SERVER NOT FOUND! You will experience performance degradation." - puts e.to_s - puts "-- BEGIN STACKTRACE --" - e.backtrace.each do |line| - puts line - end - puts "-- END STACKTRACE --" - puts "-" * 40 - - config.cache_store = :memory_store, { size: 32.megabytes } - Rails.cache = ActiveSupport::Cache.lookup_store(Rails.application.config.cache_store) - end -end diff --git a/script/install/app_server.sh b/script/install/app_server.sh index bb408dd59..a5a14d8ac 100644 --- a/script/install/app_server.sh +++ b/script/install/app_server.sh @@ -27,7 +27,7 @@ read VLAN_IP_ADDR echo "* Installing packages..." apt-get update -apt-get -y install libssl-dev build-essential automake libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel memcached libmemcached-dev git curl libcurl4-openssl-dev sendmail-bin sendmail nginx ssh coreutils ffmpeg mkvtoolnix +apt-get -y install libssl-dev build-essential automake libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel redis git curl libcurl4-openssl-dev sendmail-bin sendmail nginx ssh coreutils ffmpeg mkvtoolnix apt-get -y install libpq-dev postgresql-client apt-get -y install liblcms2-dev libjpeg-turbo8-dev libexpat1-dev libgif-dev libpng-dev libexif-dev