Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'pathname'
- # memcached requires an absolute path for the -P switch
- root = (Pathname.new(__FILE__).dirname + '..').realpath
- pidfile = root + 'tmp' + 'memcached.pid'
- if not pidfile.exist?
- puts "memcached not running: starting"
- system 'memcached', '-d', '-P', pidfile, '-l', '127.0.0.1'
- else
- puts "memcached running: stopping"
- pid = pidfile.read.chomp
- system 'kill', pid
- # it appears that memcached doesn't clean up its pid file
- # unless you send it a QUIT signal (TERM, KILL, HUP don't)
- # unfortuantely, QUIT on Mac OS X causes memcached to crash
- pidfile.delete
- end
Add Comment
Please, Sign In to add comment