0

I have installed memcache on a Dreamhost VPS (Debian GNU/Linux 5.0.9 (lenny) / memcached 1.4.10 ) for a Drupal site .

If for some reason the server needs rebooting, memcache is not restarted and Drupal spits out warnings about not being able to find memcache.

As mentioned in a previous question, I'm using the following script to start & configure memcache

 sudo /etc/init.d/memcached
  • Is it possible to call that script whenever the server is rebooted, if yes how?
  • In case, the above is not possible or fails, how and where could I tell Drupal to bypass memcache.

//pseudo code

  if( memcache == null )
    bypass memcache

EDIT

@Jon Thanks for the template but it's still above my current scripting level! Since I'm only running a single instance of memcache, here's what I have so far

 #! /bin/bash
 ### BEGIN INIT INFO
 # Provides:          memcached
 # Required-Start:    $syslog
 # Required-Stop:     $syslog
 # Should-Start:        $local_fs
 # Should-Stop:        $local_fs
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Short-Description:    memcached - Memory caching daemon
 # Description:        memcached - Memory caching daemon
 ### END INIT INFO#!/bin/sh -e

 memcached -u www-data -p 11211 -m 128 -d -l 127.0.0.1

It works fine, except that the script is not called after a server reboot! I need help to make this fit with the template structure. I have no idea about the stop or restart command...

2 Answers 2

0

If it's on debian, then install memcached with apt-get install memcached php5-memcached. It will automatically populate init.d with the required start/stop script, so first remove your tampered memcached start script from init.d and the runlevels either by deleting it manually or give out update-rc.d memcached remove. Then do the apt-get install... And it will auto start/stop each and every time.

3
  • Installing memcache has been less than straightforward. I did try apt-get install, but memcache wasn't getting configured with the correct php version.
    – PatrickS
    Jan 26, 2012 at 2:49
  • Well, If you compiled it from sources, then just remove it and use the packaged version. If you want to stick to your compiled memcached install, then get the debian memcached package and extract the init.d start/stop script from it.
    – Jauzsika
    Jan 26, 2012 at 9:57
  • packages.debian.org/lenny/memcached
    – Jauzsika
    Jan 26, 2012 at 9:58
0

The command is: update-rc.d memcached defaults

You can always man update-rc.d and get more details, but that should install the init script.

Sorry, can't answer for drupal.

3
  • taken from man update-rc.d : "System administrators are not encouraged to use update-rc.d to manage runlevels. They should edit the links directly or use runlevel editors such as sysv-rc-conf and bum instead."
    – PatrickS
    Jan 11, 2012 at 4:50
  • Sorry, unmarked as answered. I tried the update-rc.d command which seems to have updated a bunch of links but a few days later, the server was rebooted without calling the memcache script which runs fine if i call it directly as mentioned above...
    – PatrickS
    Jan 13, 2012 at 10:37
  • 2
    Oh, if you can call it without a start/stop - then that's probably why. Any script in /etc/init.d/ is supposed to be in a specific, service oriented format. Take a look at this template
    – Jon
    Jan 18, 2012 at 22:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .