Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify bin/apisix to support the SO_REUSEPORT #1085

Merged
merged 7 commits into from
Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ client_body_temp
utils/lj-releng
.idea/
*.iml

# .travis
!.travis/*.sh
29 changes: 29 additions & 0 deletions .travis/check-nginxconf.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 15 additions & 8 deletions .travis/linux_apisix_luarocks_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions bin/apisix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 %}

Expand Down
1 change: 1 addition & 0 deletions conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down