Hello!
On Thu, Oct 17, 2013 at 6:15 AM, <r...@ftbpro.com> wrote:
> I've installed openresty and i want to add the ability to convert the
> request ip to country name.
> I've used lua-geoip rock and the following code works:
>
[...]
>
> As you can see i need to open and close a file. Is there anyway i can make
> the initialization and finalization part of the code run only once (on
> nginx startup or something?) and access the geodb object in each request
> just to query the country?
>
You can use init_by_lua for it. See
https://github.com/chaoslawful/lua-nginx-module#init_by_lua
Preferably in a custom Lua module at the same time. See
https://github.com/chaoslawful/lua-nginx-module#data-sharing-within-an-nginx-worker
BTW, please join this list before posting, otherwise your posts always
require manual moderation, which is tedious. Thank you for your
cooperation!
Regards,
-agentzh