2. 关于lua中输出字符的问题点击流日志分隔符,我效仿网上一篇文章,使用了ascii不可见字符^A。开发中遇到的一个问题是,如果直接将^A写入log_format打印没有问题,但如果在lua中对输入字符串进行处理(比如原先分隔符是|,替换为^A),最终经过nginx打印,会发现打印出的不是^A,而是^A的ascii码,印象中是\x001之类,十分奇怪。目前这个问题还没有深入调查,不知大家遇到过类似问题没?
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
1. 在Nginx HttpLogModule的wiki中有这样一段话:“The size of buffer must not exceed the size of the atomic record for writing into the disk file. This size is not limited for FreeBSD 3.0-6.0.”nginx是多进程写日志,write原子性很重要。在Linux下很多人说atomic size是PIPE_BUF,即4k。但在网上查到的资料中,我经常看到将buffer大小配置为类似32k这样的大小,感到有点疑惑。写管道的时候,如果并发写大于4k,可能出现问题。但如果写普通文件,经过调研,发现nginx中在文件打开flag中加入了append标识,这样write其实是可以保证原子的。不知道大家觉得是否正确?另外总觉得用Nginx大量写IO会将主线程阻塞在磁盘io上,总感觉起个专门的磁盘IO线程更好,不知道是否有现成的模块?打算以后自己写个。
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
Best regards,
-agentzh
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
Best regards,
-agentzh
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
Regards,
-agentzh
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 107995 0.0 0.1 120792 2256 ? Ss 01:06 0:00 nginx: master process nginxsatest 107996 0.0 0.1 121188 3556 ? S 01:06 0:00 \_ nginx: worker processsatest 107997 0.0 0.1 121188 3332 ? S 01:06 0:00 \_ nginx: worker process
-r--r--r-- 1 foo foo 4805 Jun 16 01:03 /var/log/nginx/access.log
[root@zch-test-149-10 nginx]# lsof /var/log/nginx/access.logCOMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEnginx 107995 root 5w REG 253,0 5205 34747893 /var/log/nginx/access.lognginx 107996 satest 5w REG 253,0 5205 34747893 /var/log/nginx/access.lognginx 107997 satest 5w REG 253,0 5205 34747893 /var/log/nginx/access.log
[root@zch-test-149-10 nginx]# id satestuid=1003(satest) gid=1003(satest) groups=1003(satest)[root@zch-test-149-10 nginx]# id foouid=1004(foo) gid=1004(foo) groups=1004(foo)
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
---
您收到此邮件是因为您订阅了Google网上论坛上的“openresty”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到openresty+...@googlegroups.com。
要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/openresty/c91f95ff-5935-4cea-a014-5fe6b1eb88bbo%40googlegroups.com。
* The child inherits copies of the parent's set of open file descriptors. Each file descriptor in the child refers to the same open file description (see open(2)) as the corresponding file descriptor in the parent. This means that the two file descriptors share open file status flags, file offset, and signal- driven I/O attributes (see the description of F_SETOWN and F_SETSIG in fcntl(2)).
用strace观察nginx的启动过程,可以看到ngin命令先创建master进程,再clone出了两个work进程,然后调用了setuid,open调用输出太多就没没打出来了
# strace -ff -e trace=clone,setuid nginx
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f598c6eab50) = 90256
strace: Process 90256 attached
[pid 90255] +++ exited with 0 +++
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f598c6eab50) = 90257
strace: Process 90257 attached
[pid 90256] clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f598c6eab50) = 90258
strace: Process 90258 attached
[pid 90257] setuid(1003) = 0
[pid 90258] setuid(1003) = 0
订阅: 请发空白邮件到 open...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 open...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
---
您收到此邮件是因为您订阅了Google网上论坛上的“openresty”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到openresty+unsubscribe@googlegroups.com。
要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/openresty/c91f95ff-5935-4cea-a014-5fe6b1eb88bbo%40googlegroups.com。
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
---
您收到此邮件是因为您订阅了Google网上论坛上的“openresty”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到openresty+...@googlegroups.com。
要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/openresty/d518d91c-7fa7-4908-9789-5153f92dda9co%40googlegroups.com。