-
Notifications
You must be signed in to change notification settings - Fork 175
The ability to detect when nginx reload happens #914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @pyhedgehog, I am currently working on a statefile for the shared dict. It will allow to save the state of the shared dict in a file, it will also sync the dict content to the disk from time to time. Will it help? |
@xeioex I have a problem to sync dict from disk. Sync to disk is just use of |
@pyhedgehog If occasional false positives are not a problem, you can use js_periodic for this purpose. For example, with the configuration:
js_periodic always runs at least once per worker "lifespan",, right at the startup. The periodic above is set to run on worker zero only. By setting a very high interval, it is ensured that the periodic will only ever run at startup, and will never repeat / timer will never expire. False positives will occur if worker zero process is respawned as the result of a crash of worker, rather than reload. |
@jo-carter, Thank you. |
+ reloadconf (see nginx/njs#914 + norenye_api: /_/static/... and /favicon.ico via new staticfile func + rewrite test_api with class inheritance to test against several configs + tests for all API endpoints (some fixes as a result) + initial attempts to support QJS failed
Uh oh!
There was an error while loading. Please reload this page.
Problem: Cached config with externally changed config
I have module that needs changeable config (i.e. js_preload_object is not an option).
Module implements API (via js_body_content) to alter config.
Initial version of config is read from file and stored in
ngx.shared
dict.When config changed via API it updates in ngx.shared and file.
Sometimes (mostly from test scripts) I need to update file and reload nginx.
But in this case config version in ngx.shared becomes unsynced with file on disk so I need to stop/start nginx instead of reload.
Solution1
Some sort of hook - like
js_reload_hook mod.func;
directive orngx.on("reload", callback);
function.Solution2
Variable that changed on reload and can be cached. Then I can check if
r.variable.nginx_config_id
changed since storing config inngx.shared
. Such variable can be just integer that increments on each reload.The text was updated successfully, but these errors were encountered: