Ruby on Rails:Unicorn无法启动服务器

时间:2013-09-19 08:06:30

标签: ruby-on-rails capistrano unicorn

我正在关注#335 Deploying to a VPS,当我运行cap deploy:cold时,除了报告结束外,其他方式仍然正常

executing 'deploy:start'
executing "/etc/init.d/unicorn_just4magic start"
servers: ["106.XXX.XXX.XXX"]
[106.XXX.XXX.XXX] executing command
out :: 106.XXX.XXX.XXX sh: /etc/init.d/unicorn_just4magic: Permission denied
command finished in 502ms
failed: "env PATH=$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH sh -c '/etc/init.d/unicorn_just4magic start'" on 
106.XXX.XXX.XXX     

我可以在VPS上手动运行rails server,完全没问题。 但是当使用cap来部署时,我得到了上述错误。当我访问我的网站时,我得到Sorry Something went wrong提示

更新: deploy.rb是here,这里是start/restart部分

  %w[start stop restart].each do |command|
    desc "#{command} unicorn server"
    task command, roles: :app, except: {no_release: true} do
      run "/etc/init.d/unicorn_#{application} #{command}"
    end
  end

UPDATE2: 现在permission denied提示没有出现,我又遇到了另一个问题: sudo: /etc/init.d/unicorn_just4magic: command not found

我找到Capistrano deploy:start with unicornDuring cap deploy:cold - command not found for /etc/init.d/unicorn 我更改了shell脚本的行分隔符,并从git和gemfile.lock中删除了set :bundle_flags, ''。仍然得到错误

2 个答案:

答案 0 :(得分:1)

我通过在其上运行chmod +x config/unicorn_init.sh来提供本地文件/config/unicorn_init.sh可执行权限来解决它。将它推送到你的git repo,将cap部署到服务器,它对我来说就像一个魅力。

似乎不能很好地摆弄服务器上的权限。

此外,如果您似乎无法按照您的描述找到该文件("找不到命令"),请尝试使用新权限再次运行cap deploy:setup,然后从那里。由于权限问题,可能无法正确创建符号链接吗?

希望有所帮助!

答案 1 :(得分:0)

默认情况下,Unix用户对其/ home / user /目录有权限 文件unicorn_just4magic不在家庭目录或任何允许写入目录的情况下,因此您会收到“Permission demied”错误。
要解决此问题,您可以
- 将unicorn_just4magic移动到主目录下的某个位置(这可以在unicorn配置文件中设置
OR
- 为用户添加/ etc /目录的权限
$ chown your_username /etc/init.d/unicorn_just4magic

相关问题