memcached not started automatically upon boot
python /home/webapp/bin/start_memcached.py site
python /home/webapp/bin/start_django.py site
exit 0
start_memcached.py is just a script that starts memcached:
from os import system
import sys
import settings
arg = sys.argv[1]
setting = settings.MEMCACHED_SETTINGS[arg]
command = 'memcached start -d -l %s -m %d -P %s/%s_memcached.pid -p %d' % \
(setting['listen'], setting['memory'],settings.PATH, arg, setting['port'])
system(command)
print 'Started'
It just reads some configuration from settings based on some key (that's why I'm calling it with argument site).
The thing is that django is started automatically upon boot but memcached is not. If I run the start_memcached.py script manually, then it's ok. Does anybody have any suggestion how to solve this or where the problem may be?
3 Replies
Safest and most recommended option for all kinds of init/cron/anythingotherthaninteractiveshell scripts is using absolute paths.
apt-get install memcached
/etc/init.d/memcached start
That doesn't start Memcached properly on Ubuntu, because for some incomprehensible reasons the packagers decided to disable Memcached by default. You have to edit /etc/default/memcached
# Set this to yes to enable memcached.
ENABLE_MEMCACHED=yes