Skip to content

Commit ec9936c

Browse files
committed
testing stream.
1 parent 723d084 commit ec9936c

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
lines changed

DockerResources/build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
PROJECT_PATH=$(pwd)
22

3-
NGINX_VERSION=1.11.9
3+
NGINX_VERSION=1.13.6
44
NGX_DEVEL_KIT="dependencies/ngx_devel_kit-0.3.0"
5-
LUA_NGX_MOD="dependencies/lua-nginx-module-0.10.7"
5+
LUA_NGX_MOD="dependencies/lua-nginx-module-0.10.11"
66

77
export LUAJIT_LIB=/usr/local/lib
88
export LUAJIT_INC=/usr/local/include/luajit-2.1
99

1010
# make & install nginx to PROJECT_PATH/NGINX_VERSION
1111
./configure \
12+
--with-stream \
1213
--with-ld-opt="-Wl,-rpath,$LUAJIT_LIB" \
1314
--prefix=$PROJECT_PATH/$NGINX_VERSION \
1415
--add-module=$NGX_DEVEL_KIT \

DockerResources/lua/sample_disque_client.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ if not debug_port then
2424
debug_port = ngx.var.remote_addr
2525
end
2626

27-
local udpsock = ngx.socket.udp()
27+
-- local udpsock = ngx.socket.udp()
2828

29-
ok, err = udpsock:setpeername(debug_port, 7777)
30-
ngx.log(ngx.ERR, "udpsock ok:", ok, " err:", err, " debug_port:", debug_port)
29+
-- ok, err = udpsock:setpeername(debug_port, 7777)
30+
-- ngx.log(ngx.ERR, "udpsock ok:", ok, " err:", err, " debug_port:", debug_port)
3131

3232

3333

@@ -75,13 +75,13 @@ if not ws then
7575
return
7676
end
7777

78-
ngx.log(ngx.ERR, "connection:", connectionId, " start connect.")
78+
-- ngx.log(ngx.ERR, "connection:", connectionId, " start connect.")
7979

8080
function connectWebSocket()
8181
-- start receiving message from context.
8282
ngx.thread.spawn(contextReceiving)
8383

84-
ngx.log(ngx.ERR, "connection:", connectionId, " established. the_id:", the_id, " to context:", IDENTIFIER_CONTEXT)
84+
-- ngx.log(ngx.ERR, "connection:", connectionId, " established. the_id:", the_id, " to context:", IDENTIFIER_CONTEXT)
8585

8686
-- send connected to gameContext.
8787
local data = STATE_CONNECT..connectionId..the_id
@@ -211,10 +211,10 @@ function contextReceiving ()
211211
end
212212

213213
else
214-
do
215-
local ok, err = udpsock:send(sendingData)
216-
ngx.log(ngx.ERR, "udp send ok:", ok, " err:", err)
217-
end
214+
-- do
215+
-- local ok, err = udpsock:send(sendingData)
216+
-- ngx.log(ngx.ERR, "udp send ok:", ok, " err:", err)
217+
-- end
218218

219219

220220
-- send data to client

DockerResources/nginx.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,20 @@ http {
5656
content_by_lua_file lua/sample_disque_client.lua;
5757
}
5858
}
59+
}
60+
61+
stream {
62+
server {
63+
listen 7777 udp;
5964

65+
# content_by_lua_file lua/udpreceiver.lua;
66+
# content_by_lua_block {
67+
# ngx.log(ngx.ERR, "receiving udp.")
68+
# }
69+
proxy_pass 127.0.0.1:8080;
70+
71+
}
72+
log_format main '$remote_addr';
73+
access_log logs/host.access.log main;
74+
# エラーとアクセスが同時に出るの間違ってる気がするな〜〜。とはいえ動いてるのがわかった。
6075
}

rebuild.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
docker rm -f nginx_luajit
2+
docker build -f ubuntu.dockerfile -t nginx-luajit-ubuntu .
3+
docker run -ti -d --name nginx_luajit -p 8080:80 -p 7777:7777 -v $(pwd)/logs:/nginx-1.13.6/1.13.6/logs nginx-luajit-ubuntu

ubuntu.dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
FROM ubuntu
22

3-
ENV NGINX_VERSION 1.11.9
3+
ENV NGINX_VERSION 1.13.6
44
ENV LUAJIT_VERSION 2.1.0-beta2
55
ENV NGINX_DEVEL_KIT_VERSION v0.3.0
6-
ENV NGINX_LUAJIT_VERSION v0.10.7
6+
ENV NGINX_LUAJIT_VERSION v0.10.11
77

88
# ready tools.
99
RUN apt-get update && apt-get install -y \
@@ -45,5 +45,8 @@ COPY ./DockerResources/lua nginx-$NGINX_VERSION/$NGINX_VERSION/lua
4545
COPY ./DockerResources/nginx.conf nginx-$NGINX_VERSION/$NGINX_VERSION/conf/
4646

4747

48+
# このへんでudpサーバ立ち上げるか。8000あたりで。
49+
RUN apt-get install -y netcat
50+
4851
# run nginx & disque-server.
4952
ENTRYPOINT /nginx-$NGINX_VERSION/$NGINX_VERSION/sbin/nginx && /disque-master/src/disque-server

0 commit comments

Comments
 (0)