Skip to content

Commit

Permalink
fix(dockerfiles): clean up dangling sockets on startup (#10468) (#10481)
Browse files Browse the repository at this point in the history
* fix(dockerfiles): clean up dangling sockets on startup (#10468)

FTI-4525

(cherry picked from commit a6fe370)

* docs(CHANGELOG): describe fix

* Update CHANGELOG.md

Co-authored-by: Chrono <chrono_cpp@me.com>

---------

Co-authored-by: Chrono <chrono_cpp@me.com>
  • Loading branch information
locao and chronolaw authored Mar 15, 2023
1 parent e67b8c4 commit f9a332d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@
- Bumped lua-resty-session from 4.0.2 to 4.0.3
[#10338](https://github.com/Kong/kong/pull/10338)

### Fixes

#### Core

- Fixed an issue where dangling Unix sockets would prevent Kong from restarting in
Docker containers if it was not cleanly stopped.
[#10481](https://github.com/Kong/kong/pull/10481)


### 3.2.1

#### Core
Expand Down
16 changes: 16 additions & 0 deletions build/dockerfiles/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ if [[ "$1" == "kong" ]]; then
if [[ "$2" == "docker-start" ]]; then
kong prepare -p "$PREFIX" "$@"

# remove all dangling sockets in $PREFIX dir before starting Kong
LOGGED_SOCKET_WARNING=0
for localfile in "$PREFIX"/*; do
if [ -S "$localfile" ]; then
if (( LOGGED_SOCKET_WARNING == 0 )); then
printf >&2 'WARN: found dangling unix sockets in the prefix directory '
printf >&2 '(%q) ' "$PREFIX"
printf >&2 'while preparing to start Kong. This may be a sign that Kong '
printf >&2 'was previously shut down uncleanly or is in an unknown state '
printf >&2 'and could require further investigation.\n'
LOGGED_SOCKET_WARNING=1
fi
rm -f "$localfile"
fi
done

ln -sfn /dev/stdout $PREFIX/logs/access.log
ln -sfn /dev/stdout $PREFIX/logs/admin_access.log
ln -sfn /dev/stderr $PREFIX/logs/error.log
Expand Down

0 comments on commit f9a332d

Please sign in to comment.