What I'm going to explain is really about nginx processes, so maybe it can be done in nginx, or maybe its a Linux feature. In anyway, I hope it's possible.
I have an ningx
process running, that looks like this:
root 19568 ..... nginx: master (old)
app 20769 ..... nginx: worker (old)
I then send a USR2
signal to the master process: kill -USR2 19568
That gives me a new master
and worker
process:
root 19568 ..... nginx: master (old)
app 20769 ..... nginx: worker (old)
root 22716 ..... nginx: master (new)
app 22717 ..... nginx: worker (new)
So currently, the old
processes are handeling all the data. Can I tell nginx
or Ubuntu to swap those tasks to the new procceses?
Why do I need this?
I know nginx
has a reload
command to dynamically reload its config. It can even update its own executable without any downtime.
But my nginx server uses a TCP
module, so it is receiving data constantly. Because of that I cannot uses a reload
or HUP
command, because the worker processes are constantly busy. They cannot shut down.
Restarting nginx makes me loose all the client connections, and I really don't want that.
That's why I'm looking for a way to move the tasks that a certain process has to a new instance of that process.