Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun Feb 28, 2010 6:31 am 
Offline

Joined: Sun Feb 28, 2010 6:25 am
Posts: 1
I'm using Ubuntu 9.10 Server for my django-based web site and I want to run memcached automatically when booting up, so I've put the following lines to rc.local:
Code:
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:
Code:
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?


Top
   
 Post subject:
PostPosted: Sun Feb 28, 2010 12:22 pm 
Offline
Senior Member
User avatar

Joined: Tue Nov 24, 2009 1:59 pm
Posts: 362
$PATH ?

Safest and most recommended option for all kinds of init/cron/anything_other_than_interactive_shell scripts is using absolute paths.


Top
   
 Post subject:
PostPosted: Sun Feb 28, 2010 1:59 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
Why not use an init script, which is the proper way to start daemons?

Code:
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

Code:
# Set this to yes to enable memcached.
ENABLE_MEMCACHED=yes


Top
   
 Post subject:
PostPosted: Sun Feb 28, 2010 11:06 pm 
Offline
Senior Member

Joined: Thu Oct 08, 2009 5:07 pm
Posts: 99
If you have Webmin installed you can configure this in 'Startup and Shutdown.'


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group