Skip to content

Commit 9178312

Browse files
committed
2 parents 4f9ca9e + 25675b9 commit 9178312

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+124
-1198
lines changed

README.md

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
------
33
## Wiki manual
44
[https://github.com/Tinywan/lua_project_v0.01/wiki](https://github.com/Tinywan/lua_project_v0.01/wiki)
5-
## branch list
6-
+ master分支已经很稳定了,将不再提交代码,以后将从以下分支提交
7-
+ 公司`company`分支
8-
+ 家里`home`分支
95
## Project structure
106
```javascript
117
.
@@ -83,66 +79,79 @@
8379
├── index.html
8480
└── js
8581
```
82+
## Openresty Installation
83+
+ Prerequisites:`apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make build-essential`
84+
+ Building:
85+
```bash
86+
wget https://openresty.org/download/openresty-1.11.2.1.tar.gz
87+
tar xvf openresty-1.11.2.1.tar.gz
88+
cd openresty-1.11.2.1
89+
./configure --prefix=/opt/openresty \
90+
--with-pcre-jit \
91+
--with-ipv6 \
92+
--without-http_redis2_module \
93+
--with-http_iconv_module \
94+
--with-http_postgres_module \
95+
-j2
96+
make
97+
sudo make install
98+
```
99+
86100
## nginx.conf, the Nginx web server configuration
87101

88102
```bash
89103
user www www;
90104
worker_processes 8;
91105
92106
pid logs/nginx.pid;
107+
worker_rlimit_nofile 204800;
93108
94109
events {
95110
use epoll;
96-
worker_connections 1024;
111+
worker_connections 204800;
97112
}
98113
99114
http {
100115
include /opt/openresty/nginx/conf/mime.types;
101116
default_type text/html;
117+
charset utf-8;
102118
lua_package_path "/mnt/hgfs/Linux-Share/Lua/lua_project_v0.01/lualib/?.lua;;"; #lua 模块
103119
lua_package_cpath "/mnt/hgfs/Linux-Share/Lua/lua_project_v0.01/lualib/?.so;;"; #c模块
104120
include "/mnt/hgfs/Linux-Share/Lua/lua_project_v0.01/conf/domains/*";
105121
}
106122
```
107-
## Openresty安装
108-
+ 环境:`apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make build-essential`
109-
+ 下载,编译:
110-
```bash
111-
wget https://openresty.org/download/openresty-1.11.2.1.tar.gz
112-
tar xvf openresty-1.11.2.1.tar.gz
113-
cd openresty-1.11.2.1
114-
./configure --prefix=/opt/openresty --with-luajit --with-http_iconv_module
115-
make
116-
sudo make install
117-
```
118-
## 如何安装使用
119-
+ 修改主配置文件:`lua_project_v0.01/conf/nginx.conf` 的路径,一下的`/home/`修改为项目所在路径
123+
## How to use
124+
+ 修改主配置文件:`lua_project_v0.01/conf/nginx.conf` 的路径,以下的`/home/`修改为项目所在路径
120125
```bash
121126
lua_package_path "/home/lua_project_v0.01/lualib/?.lua;/home/lua_project_v0.01/application/controller/?.lua";#lua 模块
122127
lua_package_cpath "/home/lua_project_v0.01/lualib/?.so;;"; # c模块
123128
include "/home/lua_project_v0.01/conf/domains/*";
124129
```
125130
+ 测试配置文件:`test.conf`
126131
+ 修改项目路径变量:`set $project_path /home/;`
127-
+ 日志文件不支持变量(暂时是写死,以后在做处理):`access_log "/home/lua_project_v0.01/logs/demo_access.log";`
132+
+ 日志文件路径不支持变量(暂时需要修改,以后直接做跨域保存就可以了):`access_log "/home/lua_project_v0.01/logs/demo_access.log";`
128133
+ 启动脚本
129134
+ 赋予权限(655):`chmod +x /start.sh `,
130135
+ 配置成功运行结果如下:
131136
```bash
132-
/home/lua_project_v0.01/conf# ../bin/start.sh
137+
/home/lua_project_v0.01/conf# ../bin/start.sh start
133138
[ Stop OK ]
134139
nginx: the configuration file /home/lua_project_v0.01/conf/nginx.conf syntax is ok
135140
nginx: configuration file /home/lua_project_v0.01/conf/nginx.conf test is successful
136141
[ Start OK ]
137142
```
138-
+ 测试流程是否跑通:`curl http://127.0.0.1/test`,输出:"Hello! lua_project_v0.01",表示Ok
139-
## config 配置文件列表(为了测试方便)
143+
+ 测试流程是否跑通:`curl http://127.0.0.1/`,输出:`Hello! lua_project_v0.01`,表示环境配置成功
144+
## branch list
145+
+ master分支已经很稳定了,将不再提交代码,以后将从以下分支提交
146+
+ 公司`company`分支
147+
+ 家里`home`分支
148+
## config list
140149
+ API接口专用(8686):`api.conf`
141150
+ Demo测试专用(8080):`nginx_demo.conf`
142151
+ 活动直播专用(8088):`nginx_live.conf`
143152
+ Waf防火墙专用(8082):`waf.conf`
144153
+ 商品列表专用(8083):`nginx_product.conf`
145-
## 错误问题
154+
## error infomation
146155
+ [解决nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)](http://www.sjsjw.com/kf_system/article/167_16951_30655.asp)
147156
+ 错误日志:`[crit] 3478#0: *5 connect() to unix:/var/run/php7.0.9-fpm.sock failed (13: Permission denied)`
148157
+ 修改php-fpm.conf配置文件

application/controller/WebSocketRedisController.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ local channel_name, err = live_room:get("chat")
1616
if channel_name then
1717
log(ngx.ERR, " resty.websocket.server :: ",err) -- tag data origin
1818
end
19-
local redis_host = "121.41.88.209"
19+
local redis_host = "127.0.0.1"
2020
local redis_port = 63789
2121
local redis_auth = "tinywanredisamaistream"
2222
local redis_timeout = 1000
@@ -36,7 +36,7 @@ end
3636
local push = function()
3737
-- --create redis
3838
local red = redis:new()
39-
red:set_timeout(5000) -- 1 sec
39+
red:set_timeout(redis_timeout) -- 1 sec
4040
local ok, err = red:connect(redis_host, redis_port)
4141
if not ok then
4242
ngx.log(ngx.ERR, "failed to connect redis: ", err)
@@ -108,7 +108,7 @@ while true do
108108
elseif typ == "text" then
109109
--send to redis
110110
local red2 = redis:new()
111-
red2:set_timeout(1000) -- 1 sec
111+
red2:set_timeout(redis_timeout) -- 1 sec
112112
local ok, err = red2:connect(redis_host, redis_port)
113113
if not ok then
114114
ngx.log(ngx.ERR, "failed to connect redis: ", err)

bin/start.sh

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,58 @@
11
#!/bin/bash
2-
#get nginx.conf path
3-
#CONF_FILE_PATH=$(sudo find / -type f -name 'nginx.conf' | grep lua_project_v0.01 | xargs ls)
4-
# get Nginx Pid
2+
#######################################################
3+
# $Name: start.sh
4+
# $Version: v1.0
5+
# $Function: Nginx start script
6+
# $Author: ShaoBo Wan (Tinywan)
7+
# $organization: https://github.com/Tinywan
8+
# $Create Date: 2017-07-05
9+
# $Description: Nginx start script
10+
#######################################################
11+
# update 1
12+
NGINX_SBIN_PATH="/opt/openresty/nginx/sbin/nginx"
13+
# update 1
14+
NGINX_CONFIG_PATH="/mnt/hgfs/Linux-Share/Lua/lua_project_v0.01/conf/nginx.conf"
515
PID=$(ps -aef | grep nginx | grep -v grep | grep master |awk '{print $2}')
6-
if [[ $? == 0 && -n $PID ]]
7-
then
8-
echo -e "\033[35m [ Nginx running ] \033[0m"
9-
#确认nginx配置文件的语法是否正确,否则nginx将不会加载新的配置文件
10-
sudo /opt/openresty/nginx/sbin/nginx -t -c /mnt/hgfs/Linux-Share/Lua/lua_project_v0.01/conf/nginx.conf
11-
#sudo /opt/openresty/nginx/sbin/nginx -s reload
12-
sudo kill -HUP $PID
13-
echo -e "\033[33m [ Nginx has reload ] \033[0m"
14-
else
15-
echo -e "\033[31m [ Stop OK ] \033[0m"
16-
sudo /opt/openresty/nginx/sbin/nginx -t -c /mnt/hgfs/Linux-Share/Lua/lua_project_v0.01/conf/nginx.conf
17-
sudo /opt/openresty/nginx/sbin/nginx -c /mnt/hgfs/Linux-Share/Lua/lua_project_v0.01/conf/nginx.conf
18-
echo -e "\033[32m [ Start OK ] \033[0m"
19-
fi
20-
exit 1
16+
shell_usage(){
17+
echo $"Usage: $0 start|stop"
18+
}
19+
20+
start_nginx(){
21+
if [[ $? == 0 && -n $PID ]]
22+
then
23+
echo -e "\033[35m [ Nginx running ] \033[0m"
24+
sudo $NGINX_SBIN_PATH -t -c $NGINX_CONFIG_PATH
25+
sudo kill -HUP $PID
26+
echo -e "\033[33m [ Nginx has reload ] \033[0m"
27+
else
28+
echo -e "\033[31m [ Stop OK ] \033[0m"
29+
sudo $NGINX_SBIN_PATH -t -c $NGINX_CONFIG_PATH
30+
sudo $NGINX_SBIN_PATH -c $NGINX_CONFIG_PATH
31+
echo -e "\033[32m [ Start OK ] \033[0m"
32+
fi
33+
}
34+
35+
stop_nginx(){
36+
sudo kill -QUIT ${PID}
37+
if [[ $? == 0 && -n $PID ]]
38+
then
39+
echo -e "\033[33m [ Stop Success ] \033[0m"
40+
else
41+
echo -e "\033[31m [ Stop Fail ] \033[0m"
42+
fi
43+
exit 1
44+
}
45+
46+
# Main Function
47+
main(){
48+
case $1 in
49+
start) start_nginx
50+
;;
51+
stop) stop_nginx
52+
;;
53+
*) shell_usage
54+
;;
55+
esac
56+
}
57+
58+
main $1

bin/start.sh.bak

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#get nginx.conf path
3+
#CONF_FILE_PATH=$(sudo find / -type f -name 'nginx.conf' | grep lua_project_v0.01 | xargs ls)
4+
# get Nginx Pid
5+
PID=$(ps -aef | grep nginx | grep -v grep | grep master |awk '{print $2}')
6+
if [[ $? == 0 && -n $PID ]]
7+
then
8+
echo -e "\033[35m [ Nginx running ] \033[0m"
9+
#确认nginx配置文件的语法是否正确,否则nginx将不会加载新的配置文件
10+
sudo /opt/openresty/nginx/sbin/nginx -t -c /mnt/hgfs/Linux-Share/Lua/lua_project_v0.01/conf/nginx.conf
11+
#sudo /opt/openresty/nginx/sbin/nginx -s reload
12+
sudo kill -HUP $PID
13+
echo -e "\033[33m [ Nginx has reload ] \033[0m"
14+
else
15+
echo -e "\033[31m [ Stop OK ] \033[0m"
16+
sudo /opt/openresty/nginx/sbin/nginx -t -c /mnt/hgfs/Linux-Share/Lua/lua_project_v0.01/conf/nginx.conf
17+
sudo /opt/openresty/nginx/sbin/nginx -c /mnt/hgfs/Linux-Share/Lua/lua_project_v0.01/conf/nginx.conf
18+
echo -e "\033[32m [ Start OK ] \033[0m"
19+
fi
20+
exit 1

bin/stop.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

conf/domains/test.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# server live
2+
server {
3+
listen 80;
4+
server_name 127.0.0.1;
5+
charset utf8;
6+
default_type text/html;
7+
location / {
8+
content_by_lua_block {
9+
ngx.say(" Hello! lua_project_v0.01")
10+
}
11+
}
12+
}

public/resume/dist/css/fontello.min.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/resume/dist/css/print.min.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/resume/dist/css/style.min.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/resume/favicon.ico

-4.19 KB
Binary file not shown.

0 commit comments

Comments
 (0)