Commit 0709cf3e by liyijie

feat: 更新template内容,增加sidekiq配置

parent eb141795
Ohm.redis = Redic.new(ENV['REDIS_URL'])
$redis = ENV['REDIS_PASSWORD'].present? ?
Redis.new(url: ENV['REDIS_URL'], password: ENV['REDIS_PASSWORD'] ) :
Redis.new(url: ENV['REDIS_URL'])
$token_redis = Redis::Namespace.new(:token, redis: $redis)
$verify_code_redis = Redis::Namespace.new(:verify_code, redis: $redis)
$limit_redis = Redis::Namespace.new(:limit, redis: $redis)
redis_config = { url: ENV["REDIS_URL"] }
redis_config.merge!(password: ENV["REDIS_PASSWORD"]) if ENV["REDIS_PASSWORD"].present?
redis_config.merge!(db: ENV["REDIS_DB"]) if ENV["REDIS_DB"].present?
Ohm.redis = Redis.new(redis_config)
$redis = Redis.new(redis_config)
$token_redis = Redis::Namespace.new(:token, redis: $redis)
Redis::Objects.redis = Redis.new(url: ENV["REDIS_URL"], db: ENV["REDIS_DB"], password: ENV["REDIS_PASSWORD"])
redis_config = { url: ENV["REDIS_URL"] }
redis_config.merge!(password: ENV["REDIS_PASSWORD"]) if ENV["REDIS_PASSWORD"].present?
redis_config.merge!(db: ENV["REDIS_DB"]) if ENV["REDIS_DB"].present?
Sidekiq.configure_server do |config|
config.redis = redis_config
end
Sidekiq.configure_client do |config|
config.redis = redis_config
end
:concurrency: 15
:logfile: ./log/sidekiq.log
:pidfile: ./.pids/sidekiq.pid
:queues:
- default
:max_retries: 2
:schedule:
# task_scheduler_reptile:
# cron: '30 0 * * *' # 每天
# class: TaskSchedulerReptile
# description: '爬取新闻和轮播图'
# announcement_scheduler:
# cron: '0 */1 * * *' # 每1小时
# class: 'AnnouncementScheduler'
# description: '获取通知公告'
......@@ -30,6 +30,8 @@ gsub_file 'app/controllers/application_controller.rb', 'respond_to :html', 'resp
gem 'rubocop', require: false
gem 'rubocop-rails'
gem 'rubocop-performance'
gem 'sidekiq'
gem 'sidekiq-scheduler'
gem 'simple_controller', tallty: 'open-source/simple_controller'
gem 'acts_as_pasting', tallty: 'open-source/acts_as_pasting'
......@@ -124,11 +126,11 @@ after_bundle do
remove_file 'config/mongoid.yml'
copy_file 'src/config/mongoid.yml', 'config/mongoid.yml'
copy_file 'src/config/sidekiq.yml', 'config/sidekiq.yml'
remove_file 'config/storage.yml'
copy_file 'src/config/storage.yml', 'config/storage.yml'
gsub_file 'config/environments/production.rb', 'config.active_storage.service = :local', 'config.active_storage.service = :s3'
copy_file 'src/config/ohm.rb', 'config/initializers/ohm.rb'
remove_file 'config/initializers/cors.rb'
copy_file 'src/config/cors.rb', 'config/initializers/cors.rb'
remove_file 'spec/swagger_helper.rb'
......@@ -139,6 +141,7 @@ after_bundle do
copy_file 'src/app/models/user.rb', 'app/models/user.rb'
copy_file 'src/app/models/app.rb', 'app/models/app.rb'
copy_file 'src/config/redis.rb', 'config/initializers/redis.rb'
copy_file 'src/config/sidekiq.rb', 'config/initializers/sidekiq.rb'
gsub_file 'config/puma.rb', 'app_name_to_replace', app_name
gsub_file 'spec/swagger_helper.rb', 'app_name_to_replace', app_name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment