Giter Site home page Giter Site logo

Comments (7)

agentzh avatar agentzh commented on September 23, 2024

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.

 avatar commented on September 23, 2024

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.

agentzh avatar agentzh commented on September 23, 2024

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.

 avatar commented on September 23, 2024

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.

agentzh avatar agentzh commented on September 23, 2024

I'm just wondering if this is a premature optimization? ;)

Thank you very much for your contribution :)

from lua-nginx-module.

 avatar commented on September 23, 2024

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.

agentzh avatar agentzh commented on September 23, 2024

I'm fine with your suggestions here over all :)

from lua-nginx-module.

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.