chore: Detect other NGINX and offer to kill (#25478)
In the `start-https.sh` script, detect if some other process is listening on the ports we need, and if yes, inform of this, and offer to kill and proceed.
This commit is contained in:
parent
e73d066a9f
commit
3313cdadc0
|
|
@ -340,6 +340,27 @@ if [[ -f $nginx_pid ]]; then
|
||||||
unset temp_nginx_conf
|
unset temp_nginx_conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
remaining_listeners="$(
|
||||||
|
lsof -nP "-iTCP:$http_listen_port" -sTCP:LISTEN || true
|
||||||
|
lsof -nP "-iTCP:$https_listen_port" -sTCP:LISTEN || true
|
||||||
|
)"
|
||||||
|
if [[ -n $remaining_listeners ]]; then
|
||||||
|
echo $'\nThe following processes are listening on the ports we want to use:\n'"$remaining_listeners"$'\n' >&2
|
||||||
|
answer=
|
||||||
|
for attempt in 1 2 3; do
|
||||||
|
echo -n 'Kill and proceed? [y/n] ' >&2
|
||||||
|
read -rn1 answer
|
||||||
|
if [[ $answer == y ]]; then
|
||||||
|
(lsof -t "-iTCP:$http_listen_port" -sTCP:LISTEN | xargs kill) || true
|
||||||
|
(lsof -t "-iTCP:$https_listen_port" -sTCP:LISTEN | xargs kill) || true
|
||||||
|
break
|
||||||
|
elif [[ $answer == n || $attempt == 3 ]]; then
|
||||||
|
echo $'\nAborting.' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $run_as == nginx ]]; then
|
if [[ $run_as == nginx ]]; then
|
||||||
nginx -c "$nginx_dev_conf"
|
nginx -c "$nginx_dev_conf"
|
||||||
stop_cmd="nginx -c '$nginx_dev_conf' -s quit"
|
stop_cmd="nginx -c '$nginx_dev_conf' -s quit"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user