Commit 78169902 authored by ale's avatar ale Committed by samba

read master IP from /etc/noblogs/master

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