Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

touch-reload style for clearing the cache #85

Closed
unbit opened this Issue Dec 12, 2012 · 5 comments

Comments

Projects
None yet
3 participants
Owner

unbit commented Dec 12, 2012

In a project (my company website) i have added

touch-reload = .git/index

to trigger an instance reload whenever the git repository changes. This is mainly to clear the uWSGI cache as each page (after generated) is put there and served using the 'cache internal router'

Reloading the whole server (only to clear the cache) seems overkill, so a

--touch-cache-clear

would be a great (and cheap) solution

Contributor

akx commented Dec 12, 2012

Wouldn't just filemon signals + cache_clear() do?

EDIT: So as to keep the core a little bit leaner, or to have a more "hackable" solution.

Owner

unbit commented Sep 19, 2013

i think the way of "touch" files has been abused (see logrotate and logreopen). The master fifo way is a lot better for sure. We can eventually add a command to clear the cache.

@unbit unbit closed this Sep 19, 2013

I'm looking for a command to clear the cache on certain URI for instance.

Is touch-reload = .git/index the only solution ?

Owner

unbit commented Apr 19, 2017

you could map a file monitor to a uwsgi.cache_clear() api command:

uwsgi.register_file_monitor(0, "/tmp", "worker", do_clear_cache)

def do_clear_cache(signal_number, filename):
    uwsgi.cache_clear()

Thanks @unbit, is there anything that could be used with the internal routing such as http://uwsgi-docs.readthedocs.io/en/latest/InternalRouting.html#the-first-example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment