Comments (7)
Yeah, it'll be required to set cpath/path on per-request basis. But there's more complications here. Because the Lua vm is shared per worker process and users' Lua modules are cached once they're loaded, it'll not be possible to load multiple versions of the same module in different virtual servers and it'll be confusing to the end users if they're trying to do so via different cpath/path settings.
from lua-nginx-module.
I'm not sure I'd agree with the 'confusing' part. It's common with Apache, Litespeed etc to have a per-server include path for PHP. I don't see any difference between that and having a potentially different path/cpath for lua.
However, if module-loading doesn't work like includes do in PHP etc, and if the module loading isn't going to work correctly on a per-server basis, then I'll drop it for now.
I might look into a patch for Lua that would allow for the module loading to be more like PHP includes at some point, though.
from lua-nginx-module.
I didn't mean having separate search paths for each virtual server is confusing; what I meant is that due to the current implementation, it's hard to do module separation on a per virtual server basis.
I thought more about it last night and now I believe the right approach to this is to create individual lua vms for each virtual server, or it'll be impossible to load different versions of a lua module into different nginx virtual servers. Will you work on that? ;)
from lua-nginx-module.
I think a slightly better approach would be to create new per-server VMs only when required. This would be in at least the following situations:
- a path/cpath is specified in the server block that is different to the one in the http block
- a path/cpath at the http level contains a variable (I've not checked if the path can now or not)
If the server-level VM were to use the same path and cpath as the http block, there's no need to create a new VM.
This feature isn't a priority for me right now, as I'm only going to be using ngx_lua for one site at a time right now, and I'm busy trying to get Tagmata up. I'll add it to my TODO list, though, and will let you know if/when I start working on it, though. (Sorry I can't be more committal.)
from lua-nginx-module.
I'm just wondering if this is a premature optimization? ;)
Thank you very much for your contribution :)
from lua-nginx-module.
Well, it depends on how much RAM the Lua modules take up. I guess they're probably not going to take up much room, but if you have a lot of servers, they might add up. Doing a check on if the VM can be reused or not is a pretty minor bit of coding, so it might as well be added in.
Also, I think keeping variables out of the path/cpath is probably best also (as indeed you have done), so the second bullet above is unnecessary.
from lua-nginx-module.
I'm fine with your suggestions here over all :)
from lua-nginx-module.
Related Issues (20)
- ngx.say not work
- init_by_lua during Nginx config test HOT 3
- Using outer scope required modules inside an ngx.timer.at handler HOT 4
- when header_filter_by_lua_file run failed. HOT 1
- OpenResty keepalive connection appears to be hung HOT 6
- unexpected phase error when `ngx.send_header()` trigger `if_unmodified` 412 logic HOT 2
- nginx: [emerg] dlopen() "/etc/nginx/ngx_http_naxsi_module.so" failed (/etc/nginx/ngx_http_naxsi_module.so: undefined symbol: pcre_exec) in /etc/nginx/nginx.conf:9 nginx: configuration file /etc/nginx/nginx.conf test failed
- nginx: [emerg] dlopen() "/usr/local/src/nginx-1.26.1/objs/ngx_http_naxsi_module.so" failed (/usr/local/src/nginx-1.26.1/objs/ngx_http_naxsi_module.so: undefined symbol: pcre_exec) in /etc/nginx/nginx.conf:9 HOT 2
- Nginx + LibreSSL (undefined symbol: SSL_client_hello_get0_ext) HOT 3
- Possible to support `tcpsock:receive` in `balancer_by_lua` context?
- `ngx.req.set_body_data` API does not work in `balancer_by_lua` phase HOT 1
- errlog get_logs doesnt get error logs in privileged agent and visa versa HOT 3
- Core dumps with Lua nginx module and OCSP enabled on ingress-nginx HOT 2
- attempt to redefine .. in cdef HOT 1
- New module release HOT 2
- bug: memory leak when collecting response body chunks HOT 1
- ngx_http_lua_module 0.10.27 HOT 12
- Cannot remove headers set with add_header and variable value from map in http block HOT 2
- unreachable code in ngx_http_lua_util HOT 1
- possible multiple redundant comparison of functions return codes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-nginx-module.