【问题标题】:How can I clear memcache using capistrano?如何使用 capistrano 清除内存缓存?
【发布时间】:2009-03-13 16:13:56
【问题描述】:

我使用 capistrano 将我的应用程序部署到使用 memcache 的机器上。我希望 capistrano 在部署新版本的站点时清除内存缓存。

【问题讨论】:

    标签: memcached capistrano


    【解决方案1】:

    【讨论】:

    • 我发现我无法使用您链接到的 Capistrano 配方启动 memcached。然后我发现了这个:ruby-forum.com/topic/83485。这对我有用。
    【解决方案2】:

    看看这个 GIST 解决了这个问题:https://gist.github.com/matthuhiggins/668744

    【讨论】:

    • 链接似乎是垃圾邮件。
    • 也许博客已经结束了。我会在 webarchive 上获取它并发布在 gist 或类似的东西上。
    【解决方案3】:

    不知道 capistrano,但你不能直接杀死 memcached 进程并生成一个新进程吗? 也可能更好地去除碎片。

    【讨论】:

    • capistrano 是部署自动化工具,因此重启也将由 capistrano 完成。
    【解决方案4】:

    Susan Potter 的这个看起来不错https://gist.github.com/rays/154570

    # 2007 Copyright Susan Potter <me at susanpotter dot net>
    # You can read her software development rants at: http://geek.susanpotter.net
    # Released under CreativeCommons-attribution-noncommercial-sharealike license:
    # http://creativecommons.org/licenses/by-nc-sa/1.0/
    namespace :memcached do
      desc "Restart the Memcache daemon"
      task :restart, :roles => :app do
        deploy.memcached.stop
        deploy.memcached.start
      end
    
      desc "Start the Memcache daemon"
      task :start, :roles => :app do
        invoke_command "memcached -P #{current_path}/log/memcached.pid  -d", :via => run_method
      end
    
      desc "Stop the Memcache daemon"
      task :stop, :roles => :app do
        pid_file = "#{current_path}/log/memcached.pid"
        invoke_command("killall -9 memcached", :via => run_method) if File.exist?(pid_file)
      end
    end
    

    【讨论】:

      猜你喜欢
      • 2011-05-10
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-31
      • 2021-05-30
      • 2012-10-07
      • 2022-12-20
      相关资源
      最近更新 更多