Skip to content

Commit

Permalink
Merge pull request #14 from weibocom/dev
Browse files Browse the repository at this point in the history
merge dev
  • Loading branch information
rayzhang0603 authored Jun 11, 2024
2 parents f41b0e8 + 2ce325e commit 85567f6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
36 changes: 21 additions & 15 deletions install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

### BEGIN ###
# Author: idevz
Expand All @@ -20,23 +20,28 @@ OR_ROOT=$(${OR} -V &>${TMP} && cat ${TMP} |
SITE_LUALIB_ROOT=${OR_ROOT}/site/lualib
rm ${TMP}

RESTY_TIMEER_VERSION="v0.0.2"
RESTY_HTTP_VERSION="v0.12"
RESTY_CONSUL_VERSION="v0.2"

do_require() {
DEPENDENCES='
https://github.com/pintsized/lua-resty-http/archive/v0.12.tar.gz
https://github.com/idevz/lua-resty-timer/archive/v0.0.1.tar.gz
https://github.com/hamishforbes/lua-resty-consul/archive/v0.2.tar.gz
'
REQUIRE=${MOTAN_SRC_ROOT}/build/require
mkdir -p $REQUIRE/src
mkdir -p $REQUIRE/resty

for dep in ${DEPENDENCES}; do
cd $REQUIRE/src
local dependence="
https://github.com/pintsized/lua-resty-http/archive/${RESTY_HTTP_VERSION}.tar.gz
https://github.com/idevz/lua-resty-timer/archive/${RESTY_TIMEER_VERSION}.tar.gz
https://github.com/hamishforbes/lua-resty-consul/archive/${RESTY_CONSUL_VERSION}.tar.gz
"

local require=${MOTAN_SRC_ROOT}/build/require
mkdir -p "$require/src"
mkdir -p "$require/resty"

for dep in ${dependence}; do
cd "$require/src"
FILE_NAME=$(echo $dep | sed 's/.*\(lua-resty[^\/]*\)\/.*/\1/g')
# wget --no-check-certificate $dep -O $FILE_NAME
curl -fSL $dep -o $FILE_NAME
tar zxf $FILE_NAME
cp -fR $FILE_NAME*/lib/resty/* $REQUIRE/resty/
curl -fSL "$dep" -o "$FILE_NAME"
tar zxf "$FILE_NAME"
cp -fR $FILE_NAME*/lib/resty/* $require/resty/
done
}

Expand Down Expand Up @@ -68,6 +73,7 @@ build_motan_libs() {
LIB_MOTAN_TOOLS_SO=/lib/libmotan_tools.so &&
ln -sf ${SITE_LUALIB_ROOT}/motan/libs/${LIB_MOTAN_TOOLS_SO_FILE} ${LIB_MOTAN_TOOLS_SO} &&
ldconfig
cp cmotan.so ${SITE_LUALIB_ROOT}/
}

# dependence:
Expand Down
3 changes: 2 additions & 1 deletion lib/motan/server/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ end

function _M.run(self)
local sock = assert(ngx.req.socket(true))
sock:settimeout(DEFAULT_TIME_OUT)
local timeout = singletons.config.conf_set["SERVER_SOCK_TIMEOUT"] or DEFAULT_TIME_OUT
sock:settimeout(timeout)
while not ngx.worker.exiting() do
local ok, err = self:motan_server_do_request(sock)
if not ok then
Expand Down
4 changes: 3 additions & 1 deletion lib/motan/switch/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
local consts = require "motan.consts"
local utils = require "motan.utils"
local timer = require "resty.timer"
local singletons = require "motan.singletons"
local switch_shm = ngx.shared[consts.MOTAN_SWITCHER_SHM_KEY]
local setmetatable = setmetatable

Expand Down Expand Up @@ -41,7 +42,8 @@ end

function _M.run(self)
local sock = assert(ngx.req.socket(true))
sock:settimeout(DEFAULT_TIME_OUT)
local timeout = singletons.config.conf_set["SERVER_SOCK_TIMEOUT"] or DEFAULT_TIME_OUT
sock:settimeout(timeout)
while not ngx.worker.exiting() do
local switch_content = sock:receive([[*l]])
if not switch_content or switch_content == "" then
Expand Down

0 comments on commit 85567f6

Please sign in to comment.