【问题标题】:Unable to start unicorn on port 80 using capistrano无法使用 capistrano 在端口 80 上启动独角兽
【发布时间】:2013-06-14 04:41:22
【问题描述】:

cap production unicorn:start 失败并出现以下错误,尝试在端口 80 上启动我的 rails 应用程序。

F, [2013-06-14T04:33:51.420113 #13986] FATAL -- : error adding listener addr=0.0.0.0:80
/home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.2/lib/unicorn/socket_helper.rb:147:in `initialize': Permission denied - bind(2) (Errno::EACCES)
from /home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.2/lib/unicorn/socket_helper.rb:147:in `new'
from /home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.2/lib/unicorn/socket_helper.rb:147:in `bind_listen'
from /home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:229:in `listen'
from /home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:773:in `block in bind_new_listeners!'
from /home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:773:in `each'
from /home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:773:in `bind_new_listeners!'
from /home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:141:in `start'
from /home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
from /home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
from /home/ec2-user/apps/bdr_prod/shared/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'

设置 use_sudo true 返回以下错误

* executing "sudo -p 'sudo password: ' rm -rf /home/ec2-user/apps/bdr_prod/releases/20130517085418"
servers: ["64.433.69.129"]
[ec2-user@64.433.69.129] executing command
*** [err :: ec2-user@64.433.69.129] sudo
*** [err :: ec2-user@64.433.69.129] :
*** [err :: ec2-user@64.433.69.129] sorry, you must have a tty to run sudo
*** [err :: ec2-user@64.433.69.129] 
command finished in 1542ms

【问题讨论】:

  • 你是从sudo开始的吗?
  • 我正在通过 capistrano 进行部署,而不是手动执行此操作。 rvmsudo 是解决方案,不知道如何通过 cap 来实现
  • 你不想让一个 web 服务器(nginx、apache)在 80 端口上运行并转发到另一个端口或独角兽的套接字吗?

标签: ruby-on-rails capistrano unicorn


【解决方案1】:

我之前遇到过这个问题,不得不将它添加到我的deploy.rb

default_run_options[:pty] = true

【讨论】:

    【解决方案2】:

    要在远程服务器中运行 ssh sudo 命令,请在远程服务器中禁用“require tty”

    运行:

    ~$ sudo visudo

    编辑: /etc/sudoers

    # 禁用“ssh hostname sudo”,因为它会显示 密码清晰。

    # 你必须运行“ssh -t hostname sudo”。

    # 注释需要 tty

    # 默认值要求

    参考:http://www.lansweeper.com/kb/39/TTY-Required-error-during-linux-scanning.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-01
      • 2023-03-23
      • 1970-01-01
      • 2015-09-30
      • 1970-01-01
      相关资源
      最近更新 更多