Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added fab command to clear memcache on server

  • Loading branch information...
commit fcfe81e6f1fde45ec892259f8fb2fa6c19a2d96d 1 parent b73ebe5
@swaroopch authored
Showing with 19 additions and 4 deletions.
  1. +18 −4 fabfile.py
  2. +1 −0  lib/tasks/cache.rake
View
22 fabfile.py
@@ -14,6 +14,12 @@
from fabric.utils import puts
from fabric.colors import magenta
+
+env.hosts = ('isbn.net.in:30247',)
+LOCAL_DIR = os.getcwd()
+REMOTE_DIR = '/home/' + getuser() + '/web/isbn.net.in/private/isbn.net.in'
+
+
def _transfer_files(src, dst, port=22):
'''Sync from local directory to remote directory'''
assert os.getenv('SSH_AUTH_SOCK') is not None # Ensure ssh-agent is running
@@ -23,14 +29,14 @@ def _transfer_files(src, dst, port=22):
dst = dst[:-1]
local('rsync -avh --delete-before --copy-unsafe-links --exclude "log/*" --exclude ".*.sw*" --exclude "tmp/*" -e "ssh -p {0}" {1} {2}'.format(port, src, dst), capture=False)
+
@hosts('isbn.net.in:30247')
def push():
- local_dir = os.getcwd()
- remote_dir = '/home/' + getuser() + '/web/isbn.net.in/private/isbn.net.in'
+ global LOCAL_DIR, REMOTE_DIR
- _transfer_files(local_dir, env.host + ':' + remote_dir, env.port) # transfer the code
+ _transfer_files(LOCAL_DIR, env.host + ':' + REMOTE_DIR, env.port) # transfer the code
- with cd(remote_dir):
+ with cd(REMOTE_DIR):
#run("env RAILS_ENV=production rake cache:clear") # clear memcache
run("rm -vf public/index.html public/about.html") # remove page caches on disk
run("touch tmp/restart.txt") # restart passenger
@@ -43,3 +49,11 @@ def push():
sudo("start isbn.net.in") # start workers
puts(magenta('Success! The {0} server has been updated.'.format(env.host_string)))
+
+
+def clear_cache():
+ '''Clear Memcache'''
+ global REMOTE_DIR
+
+ with cd(REMOTE_DIR):
+ run("rake cache:clear")
View
1  lib/tasks/cache.rake
@@ -2,5 +2,6 @@ desc "Clear cache"
namespace :cache do
task :clear => :environment do
Rails.cache.clear
+ Rails.logger.info "Cache cleared"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.