From b10677e234625d382f201d9e2b76dc08e801b82e Mon Sep 17 00:00:00 2001
From: Yuansheng <membphis@gmail.com>
Date: Fri, 28 Feb 2020 21:27:47 +0800
Subject: [PATCH 1/3] change: disable reuseport in development mode, it more
 easy to manage.

---
 .travis/apisix_cli_test.sh | 19 +++++++++++++++++++
 bin/apisix                 |  1 +
 2 files changed, 20 insertions(+)

diff --git a/.travis/apisix_cli_test.sh b/.travis/apisix_cli_test.sh
index d67c7f837b7d..9a160c6740b3 100755
--- a/.travis/apisix_cli_test.sh
+++ b/.travis/apisix_cli_test.sh
@@ -23,6 +23,8 @@
 
 set -ex
 
+git checkout conf/config.yaml
+
 # check whether the 'reuseport' is in nginx.conf .
 make init
 
@@ -72,3 +74,20 @@ done
 
 sed -i '/dns_resolver:/,+4s/^#//'  conf/config.yaml
 echo "passed: system nameserver imported"
+
+# enable enable_dev_mode
+sed  -i 's/enable_dev_mode: false/enable_dev_mode: true/g'  conf/config.yaml
+
+make init
+
+count=`grep -c "worker_processes 1;" conf/nginx.conf`
+if [ $count -ne 1 ]; then
+    echo "failed: worker_processes is not 1 when enable enable_dev_mode"
+    exit 1
+fi
+
+count=`grep -c "listen 9080.*reuseport" conf/nginx.conf`
+if [ $count -ne 0 ]; then
+    echo "failed: reuseport should be disabled when enable enable_dev_mode"
+    exit 1
+fi
diff --git a/bin/apisix b/bin/apisix
index ea265a50b253..15f139647a47 100755
--- a/bin/apisix
+++ b/bin/apisix
@@ -696,6 +696,7 @@ local function init()
 
     if(sys_conf["enable_dev_mode"] == true) then
         sys_conf["worker_processes"] = 1
+        sys_conf["enable_reuseport"] = false
     else
         sys_conf["worker_processes"] = "auto"
     end

From e4f4b3b09847687aa0113748c2b44463d1a8e39d Mon Sep 17 00:00:00 2001
From: YuanSheng Wang <membphis@gmail.com>
Date: Tue, 9 Jun 2020 20:52:38 +0800
Subject: [PATCH 2/3] restore file conf/config.yaml

---
 .travis/apisix_cli_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis/apisix_cli_test.sh b/.travis/apisix_cli_test.sh
index 997ba7851eb8..3599a4efb094 100755
--- a/.travis/apisix_cli_test.sh
+++ b/.travis/apisix_cli_test.sh
@@ -92,7 +92,7 @@ if [ $count -ne 0 ]; then
     exit 1
 fi
 
-sed  -i 's/enable_dev_mode: true/enable_dev_mode: false/g'  conf/config.yaml
+git checkout conf/config.yaml
 
 # check whether the 'worker_cpu_affinity' is in nginx.conf .
 

From 5f1277cf52125c7090de69b6d35832365892dac4 Mon Sep 17 00:00:00 2001
From: Yuansheng Wang <membphis@gmail.com>
Date: Wed, 10 Jun 2020 09:54:31 +0800
Subject: [PATCH 3/3] bugfix: ingored the error when call `grep`.

---
 .travis/apisix_cli_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis/apisix_cli_test.sh b/.travis/apisix_cli_test.sh
index 3599a4efb094..ca31995c73f2 100755
--- a/.travis/apisix_cli_test.sh
+++ b/.travis/apisix_cli_test.sh
@@ -86,7 +86,7 @@ if [ $count -ne 1 ]; then
     exit 1
 fi
 
-count=`grep -c "listen 9080.*reuseport" conf/nginx.conf`
+count=`grep -c "listen 9080.*reuseport" conf/nginx.conf || true`
 if [ $count -ne 0 ]; then
     echo "failed: reuseport should be disabled when enable enable_dev_mode"
     exit 1