You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2017/05/14 14:22:08 UTC
[whimsy] branch master updated: Check if we are the master node
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 6a360d5 Check if we are the master node
6a360d5 is described below
commit 6a360d5bcc3571ac2e334ea4af2b119f2f48cb6f
Author: Sebb <se...@apache.org>
AuthorDate: Sun May 14 15:22:06 2017 +0100
Check if we are the master node
---
www/status/index.cgi | 10 +++++++++-
www/whimsy.rb | 17 +++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/www/status/index.cgi b/www/status/index.cgi
index 9f4ded6..fc99c7a 100755
--- a/www/status/index.cgi
+++ b/www/status/index.cgi
@@ -34,6 +34,14 @@ git_repo = `git ls-remote origin master`.strip rescue "?"
hostname = `hostname`
+# Are we the master node?
+begin
+ require_relative '../whimsy'
+ master = Whimsy.master?
+ rescue LoadError, StandardError => e
+ master = e
+end
+
# What the browser sees:
print <<-EOF
<!DOCTYPE html>
@@ -54,7 +62,7 @@ print <<-EOF
<a href="/">
<img alt="Whimsy logo" title="Whimsy logo" src="../whimsy.svg" class="logo"/>
</a>
- <h1>Whimsy Status for #{hostname}</h1>
+ <h1>Whimsy Status for #{hostname} (master=#{master})</h1>
<div class="list-group list-group-root well">
Loading...
diff --git a/www/whimsy.rb b/www/whimsy.rb
new file mode 100644
index 0000000..fb5dc06
--- /dev/null
+++ b/www/whimsy.rb
@@ -0,0 +1,17 @@
+require 'socket'
+require 'resolv'
+module Whimsy
+ # Are we the master node?
+ def self.master?()
+ Resolv::DNS.open do |rs|
+ master = rs.getaddress("whimsy.apache.org") # Official hostname as IP
+ current = rs.getaddress(Socket.gethostname) rescue nil # local as IP
+ return current == master
+ end
+ end
+end
+
+# for debugging purposes
+if __FILE__ == $0
+ puts Whimsy.master?
+end
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].