local buff = cloud.get(cachekey) --fetch sth. from upstream
buff = ngx.decode_base64(ngx.unescape_uri(buff))
local tmpath = os.tmpname()local file = io.open(tmpath, 'w')file:write(buff)io.close(file)-- expand cacheos.exec(string.format("mkdir -p '%s'; tar xf '%s' -C '%s'", file_base, tmpath, file_base))
--
邮件自: 列表“openresty”,专用于技术讨论!
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
详情: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
建议: 提问的智慧 http://wiki.woodpecker.org.cn/moin/AskForHelp
教程: http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-zhcn.html
我觉得用io库应该够用了,控制每次写入的块大小,不要一次写太多数据导致进程阻塞时间过长
On 5月25日, 上午10时10分, "boin - U know the Rules..." <mcfeeb...@gmail.com>
wrote:
> Thanks Pengqi,解惑了:)
>
> 那现在问题似乎已经进化成了寻找一个lua非阻塞的文件io方案,不知道大家有无推荐呢?
>
> 在 2012年5月25日 上午9:51,pengqi <fengm...@gmail.com>写道:
>
>
>
>
>
>
>
> > 调用os.execute实际上开销很大,而且可能会阻塞当前的worker,如果系统压力稍大,这样的做法实在不妥。最好采用lua的第3方库非阻塞的来做。
> > error log中的wait_pid failed在这种情况下是很正常的, os.execute实际上是调用c的system()函数,该函数实际上会fork一个进程来做shell,然后会阻塞式waitpid到这个子进程结束,当该子进程结束会给该worker发SIGCHLD,该worker对应的信号处理函数中会掉用waitpid来回收,但是实际上system()中已经显示的用waitpid回收掉了,所以该worker信号处理函数的waitpid回收会失败,所以在error
> > log中会写一条日志。
>
> > 在 2012年5月25日 上午8:58,Anfernee Gui <anfernee....@gmail.com>写道:
>
> > sorry, it's lua. ignore me.
>
> >> 2012/5/25 Anfernee Gui <anfernee....@gmail.com>
>
> >>> 不是很了解python,但你应该是说反了,应该是popen调用了exec家族。
>
> >>> - anfernee
>
> >>> 2012/5/25 Wendal Chen <wendal1...@gmail.com>
>
> >>>> 我也在使用类似的解决方法, 但你说的 " 不是特别稳定" ,我觉得只是os.execute执行得太快而已, 下一个周期到来的时候,
> >>>> 子进程已经执行完毕,所以wait pid failed
>
> >>>>> 建议: 提问的智慧http://wiki.woodpecker.org.cn/moin/AskForHelp
> >>>>> 教程:http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-zhcn.html
>
> >>>> --
> >>>> Wendal Chen
> >>>> GuangDong China
>
> >>>> --
> >>>> 邮件自: 列表"openresty",专用于技术讨论!
> >>>> 发言: 请发邮件到 open...@googlegroups.com
> >>>> 退订: 请发邮件至 openresty+...@googlegroups.com
> >>>> 详情:http://groups.google.com/group/openresty
> >>>> 官网:http://openresty.org/
> >>>> 仓库:https://github.com/agentzh/ngx_openresty
> >>>> 建议: 提问的智慧http://wiki.woodpecker.org.cn/moin/AskForHelp
> >>>> 教程:http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-zhcn.html
>
> >>> --
> >>> Best Regards,
> >>> Yongkun
>
> >> --
> >> Best Regards,
> >> Yongkun
>
> >> --
> >> 邮件自: 列表"openresty",专用于技术讨论!
> >> 发言: 请发邮件到 open...@googlegroups.com
> >> 退订: 请发邮件至 openresty+...@googlegroups.com
> >> 详情:http://groups.google.com/group/openresty
> >> 官网:http://openresty.org/
> >> 仓库:https://github.com/agentzh/ngx_openresty
> >> 建议: 提问的智慧http://wiki.woodpecker.org.cn/moin/AskForHelp
--
邮件自: 列表“openresty”,专用于技术讨论!
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
详情: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
建议: 提问的智慧 http://wiki.woodpecker.org.cn/moin/AskForHelp
教程: http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-zhcn.html