Commit 0740f7f0 authored by ale's avatar ale Committed by agata

read master IP from /etc/noblogs/master

parent de485a20
......@@ -4,7 +4,8 @@
//
// Stampa una mappa delle assegnazioni blog -> backend, per NGINX.
// IP interno del master.
define('NOBLOGS_MASTER', '172.16.1.10');
$master_url = file_get_contents('/etc/noblogs/master');
$noblogs_master = parse_url($master_url)['host'];
// Load wordpress api.
define('WP_CACHE',false);
......@@ -25,7 +26,7 @@ function printline($s) {
function backend_to_http_endpoint($backend) {
if (substr($backend, 0, 8) != 'backend_') {
error_log('diamine, di questo backend non so che farmene: ' . $backend);
return NOBLOGS_MASTER . ':82';
return $noblogs_master . ':82';
}
$id = substr($backend, 8);
return '172.16.1.' . $id . ':82';
......@@ -39,7 +40,7 @@ function generate_map() {
$blogs = get_blogs();
printline('map $http_host $backend_noblogs {');
printline(' default http://' . NOBLOGS_MASTER . ':82;');
printline(' default http://' . $noblogs_master . ':82;');
foreach ($blogs as $blog) {
$blog_id = $blog->blog_id;
if ($blog_id == 1)
......
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