Guest User

Untitled

a guest
Apr 25th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'pathname'
  3.  
  4. # memcached requires an absolute path for the -P switch
  5. root = (Pathname.new(__FILE__).dirname + '..').realpath
  6. pidfile = root + 'tmp' + 'memcached.pid'
  7.  
  8. if not pidfile.exist?
  9. puts "memcached not running: starting"
  10. system 'memcached', '-d', '-P', pidfile, '-l', '127.0.0.1'
  11. else
  12. puts "memcached running: stopping"
  13. pid = pidfile.read.chomp
  14. system 'kill', pid
  15.  
  16. # it appears that memcached doesn't clean up its pid file
  17. # unless you send it a QUIT signal (TERM, KILL, HUP don't)
  18. # unfortuantely, QUIT on Mac OS X causes memcached to crash
  19. pidfile.delete
  20. end
Add Comment
Please, Sign In to add comment