diff --git a/.gitignore b/.gitignore index e74c4e6a8c5a..880525d93bb8 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ client_body_temp utils/lj-releng .idea/ *.iml + +# .travis +!.travis/*.sh diff --git a/.travis/check-nginxconf.sh b/.travis/check-nginxconf.sh new file mode 100644 index 000000000000..ba8e4b783c8e --- /dev/null +++ b/.travis/check-nginxconf.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#check whether the 'reuseport' is in nginx.conf . +matched=`grep -E "listen.*reuseport" conf/nginx.conf | wc -l` +if [ $matched -eq 0 ]; then + echo "failed: nginx.conf file is missing reuseport configuration" + exit 1 +else + echo "passed: nginx.conf file contains reuseport configuration" +fi + +exit 0 diff --git a/.travis/linux_apisix_luarocks_runner.sh b/.travis/linux_apisix_luarocks_runner.sh index 8a494ffdb739..9327a477216a 100755 --- a/.travis/linux_apisix_luarocks_runner.sh +++ b/.travis/linux_apisix_luarocks_runner.sh @@ -43,20 +43,27 @@ script() { sudo mkdir -p /usr/local/apisix/deps sudo PATH=$PATH ./utils/install-apisix.sh install - sudo apisix help - sudo apisix init - sudo apisix start - sudo apisix stop + sudo PATH=$PATH apisix help + sudo PATH=$PATH apisix init + sudo PATH=$PATH apisix start + sudo PATH=$PATH apisix stop sudo PATH=$PATH ./utils/install-apisix.sh remove # install APISIX by luarocks sudo luarocks install rockspec/apisix-master-0.rockspec - sudo apisix help - sudo apisix init - sudo apisix start - sudo apisix stop + sudo PATH=$PATH apisix help + sudo PATH=$PATH apisix init + sudo PATH=$PATH apisix start + sudo PATH=$PATH apisix stop + + # make init + # 'make init' operates scripts and related configuration files in the current directory + # The 'apisix' command is a command in the /usr/local/apisix, + # and the configuration file for the operation is in the /usr/local/apisix/conf + sudo PATH=$PATH make init + sudo PATH=$PATH bash .travis/check-nginxconf.sh sudo luarocks remove rockspec/apisix-master-0.rockspec } diff --git a/bin/apisix b/bin/apisix index 69b745318d32..eea31ef21ac4 100755 --- a/bin/apisix +++ b/bin/apisix @@ -129,10 +129,10 @@ stream { server { {% for _, port in ipairs(stream_proxy.tcp or {}) do %} - listen {*port*}; + listen {*port*} {% if enable_reuseport then %} reuseport {% end %}; {% end %} {% for _, port in ipairs(stream_proxy.udp or {}) do %} - listen {*port*} udp; + listen {*port*} udp {% if enable_reuseport then %} reuseport {% end %}; {% end %} preread_by_lua_block { @@ -261,15 +261,15 @@ http { {% end %} server { - listen {* node_listen *}; + listen {* node_listen *} {% if enable_reuseport then %} reuseport {% end %}; {% if ssl.enable then %} - listen {* ssl.listen_port *} ssl {% if ssl.enable_http2 then %} http2 {% end %}; + listen {* ssl.listen_port *} ssl {% if ssl.enable_http2 then %} http2 {% end %} {% if enable_reuseport then %} reuseport {% end %}; {% end %} {% if enable_ipv6 then %} - listen [::]:{* node_listen *}; + listen [::]:{* node_listen *} {% if enable_reuseport then %} reuseport {% end %}; {% if ssl.enable then %} - listen [::]:{* node_ssl_listen *} ssl {% if ssl.enable_http2 then %} http2 {% end %}; + listen [::]:{* node_ssl_listen *} ssl {% if ssl.enable_http2 then %} http2 {% end %} {% if enable_reuseport then %} reuseport {% end %}; {% end %} {% end %} {% -- if enable_ipv6 %} diff --git a/conf/config.yaml b/conf/config.yaml index 57efc2abad9b..0e24d5c3673e 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -21,6 +21,7 @@ apisix: enable_admin_cors: true # Admin API support CORS response headers. enable_debug: false enable_dev_mode: false # Sets nginx worker_processes to 1 if set to true + enable_reuseport: true # Enable nginx SO_REUSEPORT switch if set to true. enable_ipv6: true config_center: etcd # etcd: use etcd to store the config value # yaml: fetch the config value from local yaml file `/your_path/conf/apisix.yaml`