Skip to content

Commit 4a7ae57

Browse files
committed
fix: check if port 80 or 443 is already in use before starting Envoy
Envoy doesn't exit if it can't bind ports for all its listeners, and I couldn't find any configuration option to make it do so. With this, auto-restart will kick in until both ports are no longer in use. May not be necessary after the previous fix to ensure that Kong service is stopped before Envoy service is started, but doesn't hurt to have multiple defensive measures, since it's somewhat unexpected that Envoy doesn't exit on such failures.
1 parent f02eade commit 4a7ae57

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

ansible/files/envoy.service

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Conflicts=kong.service
77
[Service]
88
Type=simple
99

10+
ExecStartPre=sh -c 'if ss -lnt | grep -Eq ":(80|443) "; then echo "Port 80 or 443 already in use"; exit 1; fi'
11+
1012
# Need to run via a restarter script to support hot restart when using a process
1113
# manager, see:
1214
# https://www.envoyproxy.io/docs/envoy/latest/operations/hot_restarter
@@ -20,8 +22,8 @@ Restart=always
2022
RestartSec=3
2123
LimitNOFILE=100000
2224

23-
# The envoy user is unpriviledged and thus not permited to bind on ports < 1024
24-
# Via systemd we grant the process a set of priviledges to bind to 80/443
25+
# The envoy user is unprivileged and thus not permitted to bind on ports < 1024
26+
# Via systemd we grant the process a set of privileges to bind to 80/443
2527
# See http://archive.vn/36zJU
2628
AmbientCapabilities=CAP_NET_BIND_SERVICE
2729

common.vars.pkr.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.1.1.20"
1+
postgres-version = "15.1.1.21"

0 commit comments

Comments
 (0)