fix pod-coverage test failutr
[rersyncrecent.git] / HOWTO.mirrorcpan
blob49ac33362266a37705891ef3d2c6eb14018b5463
1 As of this writing the single purpose for this distribution is to
2 provide a backbone for the CPAN.
4 The idea is to get a handful backbone nodes that mirror directly from
5 PAUSE and a second layer that mirrors from them. Targetting at a
6 mirroring interval of 20 seconds.
8 The rsync daemon on PAUSE runs on port 8732 and you need a password to
9 access it. There is a second rsync daemon running on the standard port
10 873 but it has very limited access policies to leave the bandwidth for
11 the backbone.
13 If you have username and password you can mirror directly from PAUSE,
14 otherwise pick your best CPAN mirror with an rsync server and try the
15 same script below for getting the quickest update cycle possible.
17 The first thing you should prepare is the CPAN tree itself on your
18 disk. The source where you take it from does not matter that much.
19 Take it from where you always took it. The setup I suggest is to
20 mirror once per day or per week or so from that old school mirroring
21 host and then again from pause in the fast loop.
23 The loop is something like this:
25     $ENV{USER}="sandy"; # fill in your name
26     $ENV{RSYNC_PASSWORD} = "secret"; # fill in you passwd
28     use File::Rsync::Mirror::Recent;
29     my @rrr = map {
30         File::Rsync::Mirror::Recent->new
31                 (
32                  ignore_link_stat_errors => 1,
33                  localroot => "/home/ftp/pub/PAUSE/$_",
34                  remote => "pause.perl.org::PAUSE/$_/RECENT.recent",
35                  max_files_per_connection => 863,
36                  rsync_options =>
37                  {
38                   port => 8732, # only for PAUSE
39                   compress => 1,
40                   links => 1,
41                   times => 1,
42                   checksum => 0,
43                  },
44                  ttl => 10,
45                  verbose => 1,
46                 )} "authors", "modules";
47     die "directory $_ doesn't exist, giving up" for grep { ! -d $_->localroot } @rrr;
48     while (){
49         my $ttgo = time + 1200; # pick less if you have a password or a mission
50         for my $rrr (@rrr){
51             $rrr->rmirror ( "skip-deletes" => 1 );
52         }
53         my $sleep = $ttgo - time;
54         if ($sleep >= 1) {
55             print STDERR "sleeping $sleep ... ";
56             sleep $sleep;
57         }
58     }
60 Don't forget to fill in your user name and password.
62 You see the 'skip-deletes' and guess, this is mirroring without doing
63 deletes. You can do it with deletes or you can leave the deletion to
64 the other, the traditional rsync loop. Worry about that later.
66 You see the option 'max_files_per_connection' which I filled with 863
67 and you need to find your favorite number. The larger the number the
68 faster the whole download goes. As you already have a mirror, you
69 probably want to take 10 or 20 times times that much. CPAN is at the
70 moment (2009-03) consisting of 142000 files. This option chunks the
71 downloads into piecemeal units and between these units the process
72 takes a peek at the most recent files to download them with higher
73 preference.
75 The localroot parameter contains your target directory. Because only
76 the authors/ and the modules/ directory are hosted by the PAUSE, you
77 need the loop over two directories. The other directories of CPAN are
78 currently not available for downloading with
79 File::Rsync::Mirror::Recent.
81 The 'port' is only needed for users who have a password for PAUSE,
82 other rsync servers listen on the rsync server port and the option can
83 be omitted.
85 The timeslice in the while loop above needs to be large enough to let
86 the rsync server survive. If you choose a random rsync server and are
87 not an rsync server yourself please be modest and choose 1200. Choose
88 less if you're offering rsync yourself and have a fat pipe, and
89 especially if you know your upstream can manage it. If you have a
90 PAUSE password choose 20 seconds. We will watch how well this works
91 and will adjust this recommendation according to our findings.
93 Set the key 'verbose' to 0 if you have no debugging demands. In this
94 case you want to omit the 'sleeping $sleep ...' noise further down the
95 script as well.
97 You can leave everything else as it stands. Start experimenting and
98 let me know how it works out.
100 -- 
101 andreas koenig