Add CTA and fix typo (#13009) (#13039)

* Add CTA and fix typo

* resolve hostname better
This commit is contained in:
Vadim Ogievetsky 2022-09-07 07:00:11 -07:00 committed by GitHub
parent ff24901fda
commit d9607a667b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 57 additions and 4 deletions

2
.gitignore vendored
View File

@ -25,5 +25,5 @@ README
.pmdruleset.xml .pmdruleset.xml
.java-version .java-version
integration-tests/gen-scripts/ integration-tests/gen-scripts/
bin/ /bin/
*.hprof *.hprof

32
examples/bin/greet Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env perl
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
use strict;
use warnings;
use Sys::Hostname qw/hostname/;
my $h = hostname;
system("host \Q$h\E >/dev/null 2>&1");
my $h_valid = !$?;
print "Starting Apache Druid.\n";
print "Open http://localhost:8888/" .
($h_valid ? " or http://$h:8888/" : "") .
" in your browser to access the web console.\n";
print "Or, if you have enabled TLS, use https on port 9088.\n"

View File

@ -55,12 +55,13 @@ sub read_config_file
my @commands; my @commands;
my @verify; my @verify;
my @notify;
my $kill_timeout; my $kill_timeout;
while (my $line = <$config_fh>) { while (my $line = <$config_fh>) {
chomp $line; chomp $line;
next if $line =~ /^(\s*\#.*|\s*)$/; next if $line =~ /^(\s*\#.*|\s*)$/;
if ($line =~ /^(:verify|:kill-timeout|(?:\!p[0-9]+\s+)?[^:]\S+)\s+(.+)$/) { if ($line =~ /^(:verify|:notify|:kill-timeout|(?:\!p[0-9]+\s+)?[^:]\S+)\s+(.+)$/) {
my $name = $1; my $name = $1;
my $order = 50; my $order = 50;
my $command = $2; my $command = $2;
@ -72,6 +73,8 @@ sub read_config_file
if ($name eq ':verify') { if ($name eq ':verify') {
push @verify, $command; push @verify, $command;
} elsif ($name eq ':notify') {
push @notify, $command;
} elsif ($name eq ':kill-timeout') { } elsif ($name eq ':kill-timeout') {
$kill_timeout = int($command); $kill_timeout = int($command);
} else { } else {
@ -92,7 +95,7 @@ sub read_config_file
} }
close $config_fh; close $config_fh;
return { commands => \@commands, verify => \@verify, 'kill-timeout' => $kill_timeout }; return { commands => \@commands, verify => \@verify, notify => \@notify, 'kill-timeout' => $kill_timeout };
} }
sub stringify_exit_status sub stringify_exit_status
@ -136,6 +139,8 @@ sub pretty
return "\x1b[1m$text\x1b[0m"; return "\x1b[1m$text\x1b[0m";
} elsif ($color eq 'red') { } elsif ($color eq 'red') {
return "\x1b[31m\x1b[1m$text\x1b[0m"; return "\x1b[31m\x1b[1m$text\x1b[0m";
} elsif ($color eq 'green') {
return "\x1b[32m\x1b[1m$text\x1b[0m";
} else { } else {
return $text; return $text;
} }
@ -236,8 +241,18 @@ $SIG{TERM} = sub { if (!$killed) { $killed = 15; $killkill = time + $opt{'kill-t
# Build up control fifo command over multiple sysreads, potentially # Build up control fifo command over multiple sysreads, potentially
my $fifobuffer = ''; my $fifobuffer = '';
# Run notification commands and print their output
for my $notify_cmd (@{$config->{notify}}) {
my $notify_output = qx[$notify_cmd 2>&1];
if (!$?) {
for my $notify_line (split /\n/, $notify_output) {
logit pretty($notify_line, 'green');
}
}
}
if (defined $opt{svlogd}) { if (defined $opt{svlogd}) {
logit "Staring services with log directory [svdir]."; logit "Starting services with log directory [$svdir].";
} else { } else {
logit "Starting services with log directory [$logdir]."; logit "Starting services with log directory [$logdir].";
} }

View File

@ -1,5 +1,6 @@
:verify bin/verify-java :verify bin/verify-java
:verify bin/verify-default-ports :verify bin/verify-default-ports
:notify bin/greet
:kill-timeout 10 :kill-timeout 10
!p10 zk bin/run-zk conf !p10 zk bin/run-zk conf

View File

@ -1,5 +1,6 @@
:verify bin/verify-java :verify bin/verify-java
:verify bin/verify-default-ports :verify bin/verify-default-ports
:notify bin/greet
:kill-timeout 10 :kill-timeout 10
!p10 zk bin/run-zk conf !p10 zk bin/run-zk conf

View File

@ -1,5 +1,6 @@
:verify bin/verify-java :verify bin/verify-java
:verify bin/verify-default-ports :verify bin/verify-default-ports
:notify bin/greet
:kill-timeout 10 :kill-timeout 10
!p10 zk bin/run-zk conf !p10 zk bin/run-zk conf

View File

@ -1,5 +1,6 @@
:verify bin/verify-java :verify bin/verify-java
:verify bin/verify-default-ports :verify bin/verify-default-ports
:notify bin/greet
:kill-timeout 10 :kill-timeout 10
!p10 zk bin/run-zk conf !p10 zk bin/run-zk conf

View File

@ -1,5 +1,6 @@
:verify bin/verify-java :verify bin/verify-java
:verify bin/verify-default-ports :verify bin/verify-default-ports
:notify bin/greet
:kill-timeout 10 :kill-timeout 10
!p10 zk bin/run-zk conf !p10 zk bin/run-zk conf

View File

@ -1,5 +1,6 @@
:verify bin/verify-java :verify bin/verify-java
:verify bin/verify-default-ports :verify bin/verify-default-ports
:notify bin/greet
:kill-timeout 10 :kill-timeout 10
!p10 zk bin/run-zk conf !p10 zk bin/run-zk conf