ddanielr commented on code in PR #5750:
URL: https://github.com/apache/accumulo/pull/5750#discussion_r2229030348
##########
assemble/bin/accumulo-service:
##########
@@ -230,14 +231,14 @@ function list_processes() {
local pid_file
local pid
local port
- pid_file="${ACCUMULO_PID_DIR}/accumulo-${process}.pid"
- pid=$(<"$pid_file")
- port=$(netstat -tnlp 2>/dev/null | grep "$pid" | awk '{print $4}' | awk -F
':' '{print $NF}' | paste -sd "," -)
- # check that only a single port was seen
- if (($(echo "$port" | grep -c -E '^[0-9]+(,[0-9]+)*$') != 1)); then
- echo "ERROR unexpected ports $(hostname) process:$process pid:$pid
ports:$port" >&2
- else
+ pid_file="$ACCUMULO_PID_DIR/accumulo-$process.pid"
+ pid=$(<"$pid_file") # read the contents of the file into the $pid variable
+ port=$(ss -tnlp 2>/dev/null | grep -F "pid=$pid," | awk '{print $4}' | awk
-F : '{print $NF}' | paste -sd,)
+
+ if [[ $port =~ ^[1-9][0-9]+(,[0-9]+)*$ ]]; then
echo "$process $pid $port"
+ else
+ echo "ERROR unexpected port format $(hostname) process:$process pid:$pid
ports:$port" >&2
Review Comment:
That's a good idea. I added a exit code after the loop in b1212f5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]