Commit 23196e99 authored by ale's avatar ale

Install our own r2db config library

This is a temporary measure until noblogs-wp is updated for ai3.
parent edce1048
Pipeline #995 passed with stages
in 1 minute and 25 seconds
......@@ -2,6 +2,8 @@ FROM registry.git.autistici.org/ai3/docker-apache2-base:master
COPY noblogs /opt/noblogs/www
COPY wp-config.php /opt/noblogs/www/wp-config.php
COPY db-config.php /opt/noblogs/www/db-config.php
COPY db-backends.php /opt/noblogs/www/r2db/db-backends.php
COPY conf /tmp/conf
COPY build.sh /tmp/build.sh
RUN /tmp/build.sh && rm /tmp/build.sh
......
<?php
function noblogs_load_backends($hashptr) {
global $wpdb;
$backend_map = array();
foreach ($noblogs_config['db_config']['backends'] as $backend_name => $backend) {
$b = array(
"host" => $backend['host'] . ":" . $backend['port'],
"user" => $backend['user'],
"password" => $backend['password'],
"name" => $backend['name'],
"dataset" => $backend,
"read" => 1,
"write" => 1,
"timeout" => 10
);
$wpdb->add_database($b);
$hashptr->addTarget($backend_name);
$backend_map[$backend_name] = $b;
}
return $backend_map;
}
function noblogs_load_global_dataset() {
global $wpdb;
$master = $noblogs_config['db_config']['master'];
if ($noblogs_config['db_config']['is_master']) {
$wpdb->add_database(array(
"host" => "127.0.0.1" . $master['port'],
"user" => $master['user'],
"password" => $master['password'],
"name" => $master['name'],
"dataset" => "global",
"read" => 1,
"write" => 1,
"timeout" => 2
));
} else {
$wpdb->add_database(array(
"host" => $master['host'] . ":" . $master['port'],
"user" => $master['user'],
"password" => $master['password'],
"name" => $master['name'],
"dataset" => "global",
"read" => 0,
"write" => 1,
"timeout" => 2
));
$wpdb->add_database(array(
"host" => "127.0.0.1:" . $master['port'],
"user" => $master['user'],
"password" => $master['password'],
"name" => $master['name'],
"dataset" => "global",
"read" => 1,
"write" => 0,
"timeout" => 2
));
}
}
<?php
// Common settings
$wpdb->persistent = true;
$wpdb->max_connections = 30;
/* Disable responsiveness check, is not needed in our configuration and is causing
connection errors for the wrong implementation */
$wpdb->check_tcp_responsiveness = false;
include_once('r2db/db-hash.php');
include_once('r2db/db-backends.php');
// Set up global dataset with master databases
noblogs_load_global_dataset();
// Add all the sharded blog databases.
$wpdb_reverse_backend_map = noblogs_load_backends($wpdb->hash_map);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment