Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
noblogs-wp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ai
noblogs-wp
Commits
cf68b44d
Commit
cf68b44d
authored
5 years ago
by
samba
Browse files
Options
Downloads
Patches
Plain Diff
use dbconf from ai3/docker/noblogs
parent
08ae3b7d
Branches
Branches containing commit
Tags
noblogs-5.6
Tags containing commit
1 merge request
!2
use dbconf from ai3/docker/noblogs
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
db-config.php
+2
-2
2 additions, 2 deletions
db-config.php
r2db/db-backends.php
+12
-59
12 additions, 59 deletions
r2db/db-backends.php
with
14 additions
and
61 deletions
db-config.php
+
2
−
2
View file @
cf68b44d
...
...
@@ -12,7 +12,7 @@ include_once('r2db/db-hash.php');
include_once
(
'r2db/db-backends.php'
);
// Set up global dataset with master databases
noblogs_load_global_dataset
(
NOBLOGS_MASTER_CONFIG
,
NOBLOGS_HOST_FILE
);
noblogs_load_global_dataset
();
// Add all the sharded blog databases.
$wpdb_reverse_backend_map
=
noblogs_load_backends
(
NOBLOGS_BACKEND_CONFIG
,
$wpdb
->
hash_map
);
$wpdb_reverse_backend_map
=
noblogs_load_backends
(
$wpdb
->
hash_map
);
This diff is collapsed.
Click to expand it.
r2db/db-backends.php
+
12
−
59
View file @
cf68b44d
<?php
function
noblogs_split_db
(
$file
)
{
$db_url
=
trim
(
file_get_contents
(
$file
));
return
parse_url
(
$db_url
);
}
// Common settings
$wpdb
->
persistent
=
true
;
$wpdb
->
max_connections
=
30
;
function
noblogs_load_backends
(
$db_config_file
,
$hashptr
)
{
global
$wpdb
;
/* Disable responsiveness check, is not needed in our configuration and is causing
connection errors for the wrong implementation */
$wpdb
->
check_tcp_responsiveness
=
false
;
$backend_map
=
array
();
include_once
(
'r2db/db-hash.php'
);
include_once
(
'r2db/db-backends.php'
);
$fp
=
@
fopen
(
$db_config_file
,
"r"
);
if
(
!
$fp
)
{
die
(
"Database backends not configured!"
);
}
while
((
$line
=
fgets
(
$fp
,
1024
))
!==
false
)
{
$wline
=
rtrim
(
$line
);
if
(
$wline
==
""
||
$wline
[
0
]
==
'#'
)
{
continue
;
}
$line_parts
=
explode
(
" "
,
$wline
);
$server_id
=
$line_parts
[
0
];
$dataset
=
"backend_"
.
$server_id
;
$backend_url
=
$line_parts
[
2
];
$backend_url_data
=
parse_url
(
$backend_url
);
$backend
=
array
(
"host"
=>
$backend_url_data
[
"host"
]
.
":"
.
$backend_url_data
[
"port"
],
"user"
=>
$backend_url_data
[
"user"
],
"password"
=>
$backend_url_data
[
"pass"
],
"name"
=>
substr
(
$backend_url_data
[
"path"
],
1
),
"dataset"
=>
$dataset
,
"read"
=>
1
,
"write"
=>
1
,
"timeout"
=>
10
);
$wpdb
->
add_database
(
$backend
);
$hashptr
->
addTarget
(
$dataset
);
$backend_map
[
$dataset
]
=
$backend
;
}
fclose
(
$fp
);
return
$backend_map
;
}
// Set up global dataset with master databases
noblogs_load_global_dataset
();
function
noblogs_load_global_dataset
(
$master_file
,
$ip_file
)
{
global
$wpdb
;
$mdata
=
noblogs_split_db
(
$master_file
);
$ldata
=
trim
(
file_get_contents
(
$ip_file
));
$globaldb
=
array
(
"host"
=>
$mdata
[
"host"
]
.
":"
.
$mdata
[
"port"
],
"user"
=>
$mdata
[
"user"
],
"password"
=>
$mdata
[
"pass"
],
"name"
=>
substr
(
$mdata
[
"path"
],
1
),
"dataset"
=>
"global"
,
"read"
=>
1
,
"write"
=>
1
,
"timeout"
=>
2
);
if
(
$mdata
[
'host'
]
==
$ldata
)
{
$wpdb
->
add_database
(
$globaldb
);
}
else
{
$globaldb
[
'read'
]
=
0
;
$wpdb
->
add_database
(
$globaldb
);
$globaldb
[
'host'
]
=
$ldata
.
":"
.
$mdata
[
"port"
];
$globaldb
[
'read'
]
=
1
;
$globaldb
[
'write'
]
=
0
;
$wpdb
->
add_database
(
$globaldb
);
}
}
// Add all the sharded blog databases.
$wpdb_reverse_backend_map
=
noblogs_load_backends
(
$wpdb
->
hash_map
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment