silence a debugging noisemaker
[rersyncrecent.git] / HOWTO.mirrorcpan
blob3b6be5327375f712072cde83ef2918a3c35e7b07
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     while (){
48         my $ttgo = time + 1200; # pick less if you have a password or a mission
49         for my $rrr (@rrr){
50             $rrr->rmirror ( "skip-deletes" => 1 );
51         }
52         my $sleep = $ttgo - time;
53         if ($sleep >= 1) {
54             print STDERR "sleeping $sleep ... ";
55             sleep $sleep;
56         }
57     }
59 Don't forget to fill in your user name and password.
61 You see the 'skip-deletes' and guess, this is mirroring without doing
62 deletes. You can do it with deletes or you can leave the deletion to
63 the other, the traditional rsync loop. Worry about that later.
65 You see the option 'max_files_per_connection' which I filled with 863
66 and you need to find your favorite number. The larger the number the
67 faster the whole download goes. As you already have a mirror, you
68 probably want to take 10 or 20 times times that much. CPAN is at the
69 moment (2009-03) consisting of 142000 files. This option chunks the
70 downloads into piecemeal units and between these units the process
71 takes a peek at the most recent files to download them with higher
72 preference.
74 The localroot parameter contains your target directory. Because only
75 the authors/ and the modules/ directory are hosted by the PAUSE, you
76 need the loop over two directories. The other directories of CPAN are
77 currently not available for downloading with
78 File::Rsync::Mirror::Recent.
80 The 'port' is only needed for users who have a password for PAUSE,
81 other rsync servers listen on the rsync server port and the option can
82 be omitted.
84 The timeslice in the while loop above needs to be large enough to let
85 the rsync server survive. If you choose a random rsync server and are
86 not an rsync server yourself please be modest and choose 1200. Choose
87 less if you're offering rsync yourself and have a fat pipe, and
88 especially if you know your upstream can manage it. If you have a
89 PAUSE password choose 20 seconds. We will watch how well this works
90 and will adjust this recommendation according to our findings.
92 Set the key 'verbose' to 0 if you have no debugging demands. In this
93 case you want to omit the 'sleeping $sleep ...' noise further down the
94 script as well.
96 You can leave everything else as it stands. Start experimenting and
97 let me know how it works out.
99 -- 
100 andreas koenig