Sphinx 重启后自动将 searchd.product.pid 所有权更改为所需所有者

发布于 2024-10-03 10:38:21 字数 906 浏览 4 评论 0原文

我的服务器中有两个用户:rootdevelopment。每次重新启动 Sphinx 时,searchd.Production.pid 的所有权始终更改为 root。不过,我总是使用development来完成任何上限、更新代码等。

我的 deploy.rb 中有这个:

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

namespace :sphinx do
  desc "Start Sphinx Searchd"
  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

但是这是使用 development 用户运行的,如果我是所有者,我只能更改文件的所有权。有什么想法吗?谢谢!

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 Searchd"
  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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情感失落者 2024-10-10 10:38:21

这不是 capistrano 问题,而是 SSH 问题。

我猜您正在从部署的同一台服务器上运行 capistrano 。

使用哪个用户来运行“cap”并不重要,真正重要的是如果您“ssh”到您的服务器,您是什么用户。

如果您是“开发”用户并通过 ssh 连接到您的服务器,那么您是什么用户?

root?,然后修复您的 .ssh/config 文件。

你的deploy.rb看起来不错,但我会用以下方法干燥它:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文