Ubuntu – memcached not restarting properly start-stop-daemon: warning: failed to kill 8175: No such process

init.dmemcachedUbuntu

im having some really weird and annoying issue with memcached. im running ubuntu server 10.04lts on a linode instance. i am using fabric with a django project and part of the fabric script allows the restart of the memcached process. today i noticed fabric outputting an error saying the following

Restarting memcached: start-stop-daemon: warning: failed to kill 8175: No such process

i then immediatley ssh'd to the box to start having a poke around to see if it was just a one off or some kind of issue with fabric. so i run the command directly on the box

Restarting memcached: start-stop-daemon: warning: failed to kill 8186: No such process

same deal different process id. i then attempted to telnet to memcached which worked fine. the process id was now 8123. a quick ps aux | grep memcached command showed that the process was running under this pid.

www-data  7259  0.0  0.1  45972   772 ?        Ssl  16:38   0:00 memcached -d -u www-data -p 11211 -m 64
www-data  8123  0.0  2.4  57220 12260 ?        Ssl  17:02   0:00 memcached -d -u www-data -p 11211 -m 64

so i thought maybe something happend during installing memcached via apt that i just didnt notice before so i removed memcached and re installed without any errors. i then got memcached running with the following options

sudo memcached -d -u www-data -p 11211 -m 64

the really strange thing is if i stop memcached and start it again, i can run /etc/init.d/memcached restart without any errors once, after that the same warning regarding the pid not being found happens all over again.

Im at my wits end with this now, Please help :/ !!

Best Answer

Forceable kill the processes running,

sudo kill -9 {process_id}

Ensure nothing is running, if /var/run/memcached.pid exists rm that too :p

Then try sudo /etc/init.d/memcachd start

Check the process id in /var/run/memcached.pid matches the one when you ps aux | grep memcache. If they do then you should be fine running sudo /etc/init.d/memcachd {start/stop/restart}

An upstart script would be cool too :)

Chris