You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

  1. # frozen_string_literal: true
  2. require_relative '../../config/boot'
  3. require_relative '../../config/environment'
  4. require_relative 'cli_helper'
  5. module Mastodon
  6. class SearchCLI < Thor
  7. option :processes, default: 2, aliases: [:p]
  8. desc 'deploy', 'Create or update an ElasticSearch index and populate it'
  9. long_desc <<~LONG_DESC
  10. If ElasticSearch is empty, this command will create the necessary indices
  11. and then import data from the database into those indices.
  12. This command will also upgrade indices if the underlying schema has been
  13. changed since the last run.
  14. With the --processes option, parallelize execution of the command. The
  15. default is 2. If "auto" is specified, the number is automatically
  16. derived from available CPUs.
  17. LONG_DESC
  18. def deploy
  19. processed = Chewy::RakeHelper.upgrade(parallel: processes)
  20. Chewy::RakeHelper.sync(except: processed, parallel: processes)
  21. end
  22. private
  23. def processes
  24. return true if options[:processes] == 'auto'
  25. num = options[:processes].to_i
  26. if num < 2
  27. nil
  28. else
  29. num
  30. end
  31. end
  32. end
  33. end