You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2020/09/14 10:12:39 UTC
[apisix] branch master updated: feat: define env in nginx.conf
template (#2174)
This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 312a97c feat: define env in nginx.conf template (#2174)
312a97c is described below
commit 312a97c96f370ec57ac99e0828a206b17aba3035
Author: seven dickens <41...@users.noreply.github.com>
AuthorDate: Mon Sep 14 18:12:29 2020 +0800
feat: define env in nginx.conf template (#2174)
Co-authored-by: lixiangyang <li...@dragonest.com>
---
.travis/apisix_cli_test.sh | 17 +++++++++++++++++
bin/apisix | 6 ++++++
conf/config-default.yaml | 2 ++
3 files changed, 25 insertions(+)
diff --git a/.travis/apisix_cli_test.sh b/.travis/apisix_cli_test.sh
index c98ed1f..efea3a2 100755
--- a/.travis/apisix_cli_test.sh
+++ b/.travis/apisix_cli_test.sh
@@ -78,6 +78,23 @@ fi
echo "passed: change default ssl port"
+# check default env
+echo "
+nginx_config:
+ envs:
+ - TEST
+" > conf/config.yaml
+
+make init
+
+grep "env TEST;" conf/nginx.conf > /dev/null
+if [ ! $? -eq 0 ]; then
+ echo "failed: failed to update env"
+ exit 1
+fi
+
+echo "passed: change default env"
+
# check nameserver imported
git checkout conf/config.yaml
diff --git a/bin/apisix b/bin/apisix
index 9573f3b..dc4fc42 100755
--- a/bin/apisix
+++ b/bin/apisix
@@ -110,6 +110,12 @@ worker_shutdown_timeout {* worker_shutdown_timeout *};
env APISIX_PROFILE;
+{% if envs then %}
+{% for _, name in ipairs(envs) do %}
+env {*name*};
+{% end %}
+{% end %}
+
{% if stream_proxy then %}
stream {
lua_package_path "$prefix/deps/share/lua/5.1/?.lua;$prefix/deps/share/lua/5.1/?/init.lua;]=]
diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index 7deb533..faa482b 100644
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -115,6 +115,8 @@ nginx_config: # config for render the template to genarate n
worker_shutdown_timeout: 240s # timeout for a graceful shutdown of worker processes
event:
worker_connections: 10620
+ #envs: # allow to get a list of environment variables
+ # - TEST_ENV
http:
access_log: "logs/access.log"
access_log_format: "$remote_addr - $remote_user [$time_local] $http_host \"$request\" $status $body_bytes_sent $request_time \"$http_referer\" \"$http_user_agent\" $upstream_addr $upstream_status $upstream_response_time"