diff --git a/conf/conf.d/ai.sggai.site.conf b/conf/conf.d/ai.sggai.site.conf index b44a084..3c94bfe 100644 --- a/conf/conf.d/ai.sggai.site.conf +++ b/conf/conf.d/ai.sggai.site.conf @@ -104,6 +104,16 @@ server { return ngx.exec(backend) end + local matched_request_log = { + method = ngx.req.get_method(), + uri = ngx.var.request_uri, + content_length = content_length, + content_type = ngx.var.http_content_type, + user_agent = ngx.var.http_user_agent, + body = body + } + ngx.log(ngx.ERR, "[ai.sggai.site] matched short POST request: ", cjson.encode(matched_request_log) or body) + ngx.status = ngx.HTTP_OK ngx.header["Content-Type"] = "application/json; charset=utf-8" ngx.say([[{ diff --git a/reload.sh b/reload.sh new file mode 100644 index 0000000..bee3f68 --- /dev/null +++ b/reload.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env sh +set -eu + +# Validate config, then reload OpenResty after conf changes. + +ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" + +cd "$ROOT_DIR" + +. "$ROOT_DIR/scripts/lib-compose.sh" + +echo "Validating Docker Compose configuration..." +compose config >/dev/null + +echo "Validating OpenResty configuration..." +compose exec -T openresty openresty -t + +echo "Reloading OpenResty..." +if compose exec -T openresty openresty -s reload; then + echo "OpenResty reloaded." +else + echo "Reload failed; restarting OpenResty..." + compose restart openresty +fi + +echo "Done."