Skip to content

Instantly share code, notes, and snippets.

@dev4dev
Created February 28, 2012 18:21
Show Gist options
  • Save dev4dev/1934126 to your computer and use it in GitHub Desktop.
Save dev4dev/1934126 to your computer and use it in GitHub Desktop.
start/stop redis-server
#!/usr/bin/env ruby -wKU
redis_bin = %x[which redis-server].strip
redis_cli = %x[which redis-cli].strip
redis_pid = '/usr/local/var/run/redis.pid'
redis_cfg = '/usr/local/etc/redis.conf'
if File.exists? redis_pid
## stop redis
print 'stopping redis-server...'
%x[#{redis_cli} -p 6379 SHUTDOWN]
print 'done'
else
## start redis
print 'starting redis-server...'
%x[#{redis_bin} #{redis_cfg}]
print 'done'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment