diff options
author | HÃ¥vard Pettersen <havardpe@gmail.com> | 2018-05-18 14:21:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-18 14:21:03 +0200 |
commit | e0129d2306ac19733fb75b96561dbc134307ed63 (patch) | |
tree | 38368e847a366f783440a20c07c4f5082006d480 | |
parent | 5a0da1b538356f2b87c0957f1722079d80612c4c (diff) | |
parent | 6ad2c1b0f14972aa6df8082e96385b032be182f4 (diff) |
Merge pull request #5891 from vespa-engine/arnej/less-perl
move perl complexity to simpler shell function
-rwxr-xr-x | config/src/apps/vespa-config/vespa-config.pl | 24 | ||||
-rwxr-xr-x | configserver/src/main/sh/start-configserver | 17 |
2 files changed, 14 insertions, 27 deletions
diff --git a/config/src/apps/vespa-config/vespa-config.pl b/config/src/apps/vespa-config/vespa-config.pl index 7f631187b58..6c0eb241959 100755 --- a/config/src/apps/vespa-config/vespa-config.pl +++ b/config/src/apps/vespa-config/vespa-config.pl @@ -266,24 +266,6 @@ sub printConfigHttpSources { print $out . "\n"; } -sub isThisAConfigServer { - my $addr; - foreach $addr (getConfigServers()) { - my $host = ""; - my $port = 0; - if ($addr =~ /(.*):(\d+)$/) { - $host = $1; - } - if ($myHostname eq $host or $host eq "localhost") { - print "yes\n"; - exit 0; - } - } - - print "no\n"; - exit 1; -} - # Perl trim function to remove whitespace from the start and end of the string sub trim($) { my $string = shift; @@ -299,7 +281,7 @@ sub getLastLine { sub usage { print "usage: "; - print "vespa-config [-configsources | -confighttpsources | -zkstring | -configserverport | -zkclientport | -isthisaconfigserver]\n"; + print "vespa-config [-configsources | -confighttpsources | -zkstring | -configserverport | -zkclientport]\n"; } if ( @ARGV == 0 ) { @@ -334,10 +316,6 @@ if ( $ARGV[0] eq "-zkclientport" ) { print "$zk_client_port\n"; exit 0; } -if ( $ARGV[0] eq "-isthisaconfigserver" ) { - isThisAConfigServer(); - exit 0; -} usage(); exit 1; diff --git a/configserver/src/main/sh/start-configserver b/configserver/src/main/sh/start-configserver index f476fbb89a0..03ce136e13c 100755 --- a/configserver/src/main/sh/start-configserver +++ b/configserver/src/main/sh/start-configserver @@ -98,10 +98,19 @@ fixddir ${VESPA_HOME}/var/zookeeper fixfile ${VESPA_HOME}/var/zookeeper/myid fixddir ${VESPA_HOME}/var/zookeeper/version-2 -${VESPA_HOME}/libexec/vespa/vespa-config.pl -isthisaconfigserver 1>/dev/null -if [ "$?" != "0" ] ; then - echo "Not able to start config server, host `hostname` is not part of 'VESPA_CONFIGSERVERS'" - exit 1; +not_a_configserver () { + for hn in $(vespa-print-default configservers); do + if [ "$hn" = localhost ] || [ "$hn" = "${VESPA_HOSTNAME}" ]; then + return 1 + fi + done + return 0 +} + +if not_a_configserver ; then + echo "Will not start config server, host ${VESPA_HOSTNAME}" \ + "is not part of VESPA_CONFIGSERVERS: " $(vespa-print-default configservers) + exit 1 fi fixlimits |