开发者

Automatic change searchd.production.pid ownership to desired owner after Sphinx restart

I have two users in my server: root and development. Everytime Sphinx is restarted, the ownership of searchd.production.pid always changed to root. I always use the development to do any cap, update code, etc. though.

I have this in my deploy.rb:

after "deploy:update_code", "sphinx:stop"
after "deploy:migrate", "sphinx:start"

namespace :sphinx do
  desc "Start Sphinx Sear开发者_高级运维chd"
  task :start, :roles => :app do
    run "cd #{deploy_to}/current/; /usr/bin/rake ts:start RAILS_ENV=#{rails_env}"
  end

  desc "Stop Sphinx Searchd"
  task :stop, :roles => :app do
    run "cd #{deploy_to}/current/; /usr/bin/rake ts:stop RAILS_ENV=#{rails_env}"
  end
  desc "Restart Sphinx Searchd"
  task :restart, :roles => :app do
    run "cd #{deploy_to}/current/; /usr/bin/rake ts:restart RAILS_ENV=#{rails_env}"
  end
end

But then this is run using development user, I can only change the ownership of a file if I am the owner. Any idea? Thanks!


This is not a capistrano issue but SSH.

I guess you are running capistrano from the same server to which you are deploying.

It doesn't matter what user do you use to run 'cap', what it really matters is what user you are if you 'ssh' to your server.

If you are 'development' user and ssh to your server, what user are you ?

root?, then fix your .ssh/config file.

Your deploy.rb looks good, but I would DRY it with:

namespace :sphinx do
  desc "Start Sphinx Searchd"
  task :start, :roles => :app do
    rake "ts:start"
  end

  desc "Stop Sphinx Searchd"
  task :stop, :roles => :app do
    rake "ts:stop"
  end
  desc "Restart Sphinx Searchd"
  task :restart, :roles => :app do
    rake "ts:restart"
  end
end

def rake(rake_task)
  if rake_task
    raise "Rails environment not set" unless rails_env
    run "cd #{current_path} && rake #{rake_task} RAILS_ENV=#{rails_env}"
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜