3
0
mirror of https://github.com/rvalitov/zabbix-php-fpm.git synced 2023-11-05 03:30:27 +01:00

[fix] port calculation

This commit is contained in:
Ramil Valitov 2020-07-07 22:40:51 +03:00
parent cbaff4a688
commit e81131bbcd
No known key found for this signature in database
GPG Key ID: 2AB186DABDFE1914

View File

@ -85,14 +85,14 @@ setupPool() {
copyPool "$POOL_FILE" "$POOL_NAME" "$POOL_SOCKET" "ondemand"
done
PHP_SERIAL_ID=$(find /etc/php/ -maxdepth 1 -mindepth 1 -type d | sort | grep -n -F "7.3" | cut -d : -f 1)
PHP_SERIAL_ID=$(find /etc/php/ -maxdepth 1 -mindepth 1 -type d | sort | grep -n -F "$PHP_VERSION" | cut -d : -f 1)
#Create TCP port based pools
#Division on 1 is required to convert from float to integer
START_PORT=$(echo "($MIN_PORT + $PHP_SERIAL_ID * $MAX_PORTS_COUNT + 1)/1" | bc)
for ((c = 1; c <= MAX_PORTS; c++)); do
POOL_NAME="port$c"
POOL_PORT=$(echo "($START_PORT + $c)/1" | bc)
PORT_IS_BUSY=$(sudo lsof -i:$POOL_PORT)
PORT_IS_BUSY=$(sudo lsof -i:"$POOL_PORT")
assertNull "Port $POOL_PORT is busy" "$PORT_IS_BUSY"
copyPool "$POOL_FILE" "$POOL_NAME" "$POOL_PORT" "static"
done
@ -101,7 +101,7 @@ setupPool() {
POOL_NAME="localhost"
POOL_PORT=$(echo "($MIN_PORT + $PHP_SERIAL_ID * $MAX_PORTS_COUNT)/1" | bc)
POOL_SOCKET="127.0.0.1:$POOL_PORT"
PORT_IS_BUSY=$(sudo lsof -i:$POOL_PORT)
PORT_IS_BUSY=$(sudo lsof -i:"$POOL_PORT")
assertNull "Port $POOL_PORT is busy" "$PORT_IS_BUSY"
copyPool "$POOL_FILE" "$POOL_NAME" "$POOL_SOCKET" "static"