unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.45k stars 691 forks source link

uwsgi max-worker-lifetime not reloading workers after prescribed time #867

Closed phalgun closed 8 years ago

phalgun commented 9 years ago

My uwsgi configuration looks like this -

#socket file's location
socket = /my/path/%n.sock

#permissions for the socket file
chmod-socket    = 666

post-buffering = 8192

processes = 4

stats = /tmp/stats.socket

single-interpreter = true

harakiri = 40

harakiri-verbose = true

max-worker-lifetime = 43200

I use emperor to run uwsgi -

description "uWSGI"
start on runlevel [2345]
stop on runlevel [06]
respawn

env UWSGI=/var/www/v4/venv/bin/uwsgi
env LOGTO=/var/log/uwsgi/emperor.log

exec $UWSGI --master --emperor /etc/uwsgi/vassals --die-on-term --uid nobody --gid nogroup --logto $LOGTO 

But the workers do not reload after the prescribed time of 43200 seconds. I read that master should be enabled for max-worker-lifetime to work and I have indeed enabled as you see in the second config snippet.

Is there anything I'm doing wrong? How do I get my workers to gracefully reload once in a while.

unbit commented 9 years ago

The option you are searching for is 'idle'. max-worker-lifetime is used by monitor-reloader (like reload-on-rss, max-requests and so on)

phalgun commented 9 years ago

Could I use the max-requests option instead to reload the workers periodically?

unbit commented 9 years ago

It is a sub-optimal approach, uWSGI offers better ways to reload (generally those based on memory are the most useful)

xrmx commented 8 years ago

Looks resolved, I think we can close this.

kurtismullins commented 8 years ago

@unbit

It is a sub-optimal approach, uWSGI offers better ways to reload (generally those based on memory are the most useful)

I know this probably isn't the best channel to ask you about this, but it came up high in my Google search. I am also in the process of enabling max-requests and max-worker-lifetime because our app tends to fill up on memory after a while.

Can you expand upon those "better ways to reload (generally those based on memory)" or point me towards a link? I've read over the documentation quite a bit, but didn't see anything along those lines.

Thanks!

twz915 commented 7 years ago

+1 @unbit @kurtismullins I have the same question.

twz915 commented 7 years ago

@kurtismullins This may be helpful https://github.com/unbit/uwsgi/issues/1458

164747 commented 6 years ago

I had this problem. Someone suggested using the worker-reload-mercy config option. I set

worker-reload-mercy=5

in my config (60 is default). Seem to solve my issue.