Code Monkey home page Code Monkey logo

Comments (17)

zhuzhaoyuan avatar zhuzhaoyuan commented on May 22, 2024

Hi,多谢反馈。
请问有在配置文件里显式的load这个模块吗?比如像这样:
worker_processes 1;

dso {
load ngx_http_lua_module.so;
load ngx_http_memcached_module.so;
}

events {
worker_connections 1024;
}

from tengine.

wangbin579 avatar wangbin579 commented on May 22, 2024

配置了,我的nginx hmux动态编译后,模块运行没有问题。
但另外一个系统,因为config文件配置了多个模块,就有问题了

from tengine.

monadbobo avatar monadbobo commented on May 22, 2024

@wangbin579 你使用的是那个版本? 可以使用下master分支上最新的版本再试试。

谢谢!

from tengine.

wangbin579 avatar wangbin579 commented on May 22, 2024

应该就是master最新版本。

[root@bgp176_161 sbin]# ./nginx_dso -v
Tengine version: Tengine/1.4.1 (nginx/1.2.3)

from tengine.

zhuzhaoyuan avatar zhuzhaoyuan commented on May 22, 2024

@wangbin579 你私信里和我说是因为静态编译里已经有这个模块,但是有动态链接了?

from tengine.

zhuzhaoyuan avatar zhuzhaoyuan commented on May 22, 2024

@wangbin579 一个模块只能被加入一次。如果静态和动态都加入了同一模块(根据模块名称来判断),则以静态编译的模块优先。你期待的行为是什么?

from tengine.

wangbin579 avatar wangbin579 commented on May 22, 2024

利用静态编译的版本,只是说明配置文件已经有dso配置了

from tengine.

zhuzhaoyuan avatar zhuzhaoyuan commented on May 22, 2024

你之前静态编译的时候是不是加了--add-module选项把这个模块静态编译进去了,然后又使用编译出来的这个tengine版本加dso选项?

from tengine.

wangbin579 avatar wangbin579 commented on May 22, 2024

不是,分开的。

经过试验,如果config中只有一个模块,就不会报unknown directive "xxxxxx" in /usr/local/nginx/etc/nginx.conf:60,多个模块,就有问题

from tengine.

zhuzhaoyuan avatar zhuzhaoyuan commented on May 22, 2024

我自己试了一下加载多个模块是没问题的。
能不能搞一个能重现的最小步骤?多谢啦。

from tengine.

wangbin579 avatar wangbin579 commented on May 22, 2024

好,我明天搞一个最小测试集,独立出来

from tengine.

wangbin579 avatar wangbin579 commented on May 22, 2024

经过我们测试,如果在config写两个模块的配置,比如

ngx_addon_name=ngx_http_hello_module
HTTP_MODULES="$HTTP_MODULES ngx_http_hello_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_hello_module.c"

ngx_addon_name=ngx_http_ok_module
HTTP_MODULES="$HTTP_MODULES ngx_http_ok_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_ok_module.c"

利用dso_tool编译,情况如下:

  • ngx_http_ok_module will be compiled
    gcc -c -pipe -O ...
    -o objs/src/webserver/ngx_hello_module.o
    ..../ngx_hello_module.c
    gcc -c -pipe -O ...
    -o objs/src/webserver/ngx_ok_module.o
    .../ngx_ok_module.c
    gcc -rdynamic -fPIC -shared -o objs/ngx_http_ok_module.so
    objs/src/webserver/ngx_hello_module.o
    objs/src/webserver/ngx_ok_module.o
    -lpthread -ldl -lcrypt -lpcre -lssl -lcrypto -ldl -lz
    copying objs/ngx_http_ok_module.so to /usr/local/nginx/modules

配置了nginx.conf

dso {
load ngx_http_ok_module.so;
}

运行:

[root@bgp176_161 sbin]# ./nginx
nginx: [emerg] unknown directive "hello" in /usr/local/nginx/conf/nginx.conf:68

其中:

ngx_http_hello_module模块(http://blog.zhuzhaoyuan.com/2009/08/creating-a-hello-world-nginx-module/)

ngx_http_ok_module把hello改成ok后的模块

from tengine.

monadbobo avatar monadbobo commented on May 22, 2024

@wangbin579 是的,现在dso_tools不支持一个config里面写多个module,因为有一个问题很难解决,那就是config里面的NGX_ADDON_SRCS变量,我执行完config之后,无法知道每个模块都需要那些源文件。。除非新创建一个config文件的写法。。不过这个我会再考虑下如何兼容这种情况,因为我们这边有些模块也有这个问题。。

谢谢!

from tengine.

wangbin579 avatar wangbin579 commented on May 22, 2024

ngx_addon_name=ngx_http_hello_module
HTTP_MODULES="$HTTP_MODULES ngx_http_hello_module ngx_http_ok_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_hello_module.c $ngx_addon_dir/ngx_ok_module.c"

如果dso编译,这样也出现上面同样的问题,如果是静态编译,就没有问题

from tengine.

monadbobo avatar monadbobo commented on May 22, 2024

@wangbin579 你如果这样子写,那么dos_tools就更不知道编译.so应该用那个源文件了。。

所以还是推荐你分成两个config。。

谢谢!

from tengine.

wangbin579 avatar wangbin579 commented on May 22, 2024

分开确实是一种方法,但对于很多系统,还是很麻烦的

from tengine.

monadbobo avatar monadbobo commented on May 22, 2024

@wangbin579 恩,我后续会想想看有其他的解决方法没,这个版本,暂时只能分开了。

谢谢!

from tengine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.