You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@whimsical.apache.org by sebb AT ASF <se...@apache.org> on 2017/05/11 15:47:20 UTC

Re: [whimsy] branch master updated: Add test for Whimsy master

The code below works for the current vm3/vm4 hosts.
But there are lots of ways to set up a system, and it may be that some
setups won't return the external address for the local hostname.
i.e. getaddress() might return the local network address.
In fact that is what happens if one uses Resolv.getaddress() instead.

Since no diff mails will be sent if there is no master, it occurred to
me that it might be sensible to put the code into a utility that can
be checked by Ping My Box?

Thoughts?

On 11 May 2017 at 14:58,  <se...@apache.org> wrote:
> 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  c6ea38e   Add test for Whimsy master
> c6ea38e is described below
>
> commit c6ea38e993b2aff074de3a018b58df7895aaa8bc
> Author: Sebb <se...@apache.org>
> AuthorDate: Thu May 11 14:56:08 2017 +0100
>
>     Add test for Whimsy master
> ---
>  www/test.cgi | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/www/test.cgi b/www/test.cgi
> index 17f35ab..c4b10ae 100755
> --- a/www/test.cgi
> +++ b/www/test.cgi
> @@ -37,5 +37,20 @@ if query and not query.empty? and ENV['SCRIPT_URL'] == '/test.cgi'
>        sleep wait
>        print " done waiting\n"
>      end
> +    require 'socket'
> +    hostname = Socket.gethostname
> +    require 'resolv'
> +    master = nil
> +    current = nil
> +    Resolv::DNS.open do |rs|
> +      master = rs.getaddress("whimsy.apache.org")
> +      current = rs.getaddress(hostname) rescue nil
> +    end
> +    print "master: #{master} current: #{current}\n"
> +    if current == master
> +      print "This system is the Whimsy master\n"
> +    else
> +      print "This system is not the Whimsy master\n"
> +    end
>      print "All done\n"
>  end
>
> --
> To stop receiving notification emails like this one, please contact
> ['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].