Reputation: 797
I am using a digitalocean ubuntu 14.04 vps. When I run
sudo lsof -i:9000
I get varying results such as
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
gunicorn 23148 django 5u IPv4 51019 0t0 TCP localhost:9000 (LISTEN)
or
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
gunicorn 23174 django 5u IPv4 51179 0t0 TCP localhost:9000 (LISTEN)
gunicorn 23175 django 5u IPv4 51179 0t0 TCP localhost:9000 (LISTEN)
where the number of gunicorn processes varies from 0-4, even if I run lsof immediately after the previous attempt. Simply running
pkill gunicorn
is failing, I believe because the PIDs are constantly changing (as shown above). How can I kill these processes permanently? If it makes a difference, I am user "root", and do not have a login for user "django"
Upvotes: 2
Views: 8641
Reputation: 599778
lsof
will only show the child processes which are actually binding to the port. You need to kill the master process. If you start gunicorn with the --pid
option you can give it a filename to store the PID of that process in, then you can kill it directly; if not you can get it from ps|grep gunicorn
.
Even better, as elethan suggests in the comments, set up gunicorn as a service using whatever process manager exists on your system - systemd, upstart, supervisor, or whatever - and use that to start and stop it.
Upvotes: 7