4 use lib
"$ENV{LJHOME}/cgi-bin";
7 die "Don't use this in web context, it's only for admin scripts!"
8 if LJ
::is_web_context
();
12 my $cid = shift or die "no cid passed\n";
15 print STDERR
" - cluster $cid... " if $verbose;
17 my $role = LJ
::get_inactive_role
($cid);
20 $LJ::DBIRole
->clear_req_cache();
21 my $db = LJ
::get_dbh
($role);
23 $db->{RaiseError
} = 1;
28 sub validate_clusters
{
31 foreach my $cid (@LJ::CLUSTERS
) {
32 unless (LJ
::DBUtil
->get_inactive_db($cid)) {
33 print STDERR
" - found downed cluster: $cid (inactive side)\n";
34 print STDERR
"Aborted. Please try again later.\n";
42 ## get cluster DB handler, preferred order: inactive DB, active DB
43 sub connect_to_cluster
{
48 my $dbr = LJ
::DBUtil
->get_inactive_db($clid, $verbose);
50 warn "Using master database for cluster #$clid"
52 $dbr = LJ
::get_cluster_reader
($clid);
55 die "Can't get DB connection for cluster #$clid"
57 $dbr->{RaiseError
} = 1;
59 warn "Connected to cluster #$clid" if $verbose;