in another way, use timer update nginx/openresty local info; define a new location, other App get info from this new location.
On 日, 2019-05-05 at 03:55 -0700, Hadi Abbasi wrote:
Hey friends...
I have 4 nginx processes by setting:
worker_processes 4;
when I run:
init_worker_by_lua_block {
print("Hello World")
}
it will print 4 Hello World msgs at the console logs (normally one log for each worker)!
because init_worker_by_lua_block is the initialization place for each worker!
so when I use this, timer will be executed 4 times:
init_worker_by_lua_block {
ngx.timer.at(0.0,
function(param)
ngx.timer.every(timeout,sendHttpRequestFunc)
-- or make http socket connection from here
sendHttpRequestFunc()
end)}
I need to have my info structure inside my lua project and other api will send me that data via socket connection!
but this method will run 4 times at intervals and once at the first time!
when I wanna run ngx.timer.at from init_by_lua_block as initialization of master process, it will throw an error like:
init_by_lua error: init_by_lua:11: no request
stack traceback:
[C]: in function 'at'
so I know that I can't run any timer and socket function from init_by_lua_block,
but I need to run an info structure refresh request once each 5 minutes to updating my info structure...
how can I do it independent of users requests?
thanks a lot..
Best,
Hadi
.