Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parallelization to tootctl search deploy #12051

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clean up
Gargron authored Oct 2, 2019
commit cfbf66ce44f407ad52b4feb7025d13b187bba348
18 changes: 13 additions & 5 deletions lib/mastodon/search_cli.rb
Original file line number Diff line number Diff line change
@@ -15,19 +15,27 @@ class SearchCLI < Thor
This command will also upgrade indices if the underlying schema has been
changed since the last run.

With the --parallel option, Execute tasks in parallel. The default is 2,
which specifies the number of processors. If 'auto' is specified,
it is automatically derived.
With the --parallel option, specify the number of processes to run the command
with. The default is 2. If 'auto' is specified, the number is automatically
derived from available CPUs.
LONG_DESC
def deploy
processed = Chewy::RakeHelper.upgrade parallel: parallel
Chewy::RakeHelper.sync(except: processed)
Chewy::RakeHelper.sync(except: processed, parallel: parallel)
end

private

def parallel
options[:parallel] == 'auto' ? true : Integer(options[:parallel], exception: false) || false
return true if options[:parallel] == 'auto'

num = options[:parallel].to_i

if num < 2
nil
else
num
end
end
end
end