]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-init
init: add -j / --jobs parameter
[public-inbox.git] / script / public-inbox-init
index 6221871e1bde392e618660100b36489995222d22..00147db557884cbc3d820da4ae05f96c7e8ee7e0 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# Copyright (C) 2014-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2014-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Initializes a public-inbox, basically a wrapper for git-init(1)
@@ -27,10 +27,12 @@ use Cwd qw/abs_path/;
 my $version = undef;
 my $indexlevel = undef;
 my $skip_epoch;
+my $jobs;
 my %opts = (
        'V|version=i' => \$version,
        'L|indexlevel=s' => \$indexlevel,
        'S|skip|skip-epoch=i' => \$skip_epoch,
+       'j|jobs=i' => \$jobs,
 );
 GetOptions(%opts) or usage();
 PublicInbox::Admin::indexlevel_ok_or_die($indexlevel) if defined $indexlevel;
@@ -144,6 +146,12 @@ my $ibx = PublicInbox::Inbox->new({
 });
 
 my $creat_opt = {};
+if (defined $jobs) {
+       die "--jobs is only supported for -V2 inboxes\n" if $version == 1;
+       die "--jobs=$jobs must be >= 1\n" if $jobs <= 0;
+       $creat_opt->{nproc} = $jobs;
+}
+
 PublicInbox::InboxWritable->new($ibx, $creat_opt)->init_inbox(0, $skip_epoch);
 
 # needed for git prior to v2.1.0