【问题标题】:Unicorn fails to start on Vagrant box due to Errno::EPERM由于 Errno::EPERM,Unicorn 无法在 Vagrant box 上启动
【发布时间】:2013-05-05 19:35:49
【问题描述】:

当我在我的 Vagrant box(ubuntu-12.04.2-server-i386) 上运行以下命令为 Sinatra 应用程序启动 Unicorn 时

sudo unicorn -c unicorn.rb -E development -D -l 0.0.0.0:8080

我在 Unicorn 日志中收到以下错误。

I, [2013-05-05T19:15:15.538805 #2357]  INFO -- : listening on addr=0.0.0.0:8080 fd=5
F, [2013-05-05T19:15:15.541673 #2357] FATAL -- : error adding listener addr=/home/vagrant/tmp/myapp/sockets/unicorn.sock
/home/vagrant/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.3.1/lib/unicorn/socket_helper.rb:140:in `initialize': Operation not permitted - "/home/vagrant/tmp/myapp/sockets/unicorn.sock" (Errno::EPERM)

我以 vagrant 用户身份登录,并按照http://recipes.sinatrarb.com/p/deployment/nginx_proxied_to_unicorn 配置了 unicorn.rb

@dir = '/home/vagrant/myapp/'

worker_processes 4
working_directory @dir

timeout 30

listen "#{@dir}tmp/sockets/unicorn.sock", :backlog => 64
pid "#{@dir}tmp/pids/unicorn.pid"

stderr_path "#{@dir}log/unicorn.stderr.log"
stdout_path "#{@dir}log/unicorn.stdout.log"

我查看了代码,但无法初始化以下内容

Kgio::UNIXServer.new('0.0.0.0:8080')

【问题讨论】:

  • 我刚刚开始遇到与 Rails 应用程序完全相同的问题。与您的配置非常相似。

标签: unicorn vagrant


【解决方案1】:

Unicorn 无法将 .sock 文件存储在 Virtual Box 共享文件夹中,因此您需要做的就是从这里修改套接字:

listen "#{@dir}tmp/sockets/unicorn.sock", :backlog => 64

到这里:

listen "/tmp/sockets/unicorn.sock", :backlog => 64

或 VBox 共享文件夹之外的其他位置。

【讨论】:

  • 如果此选项由于某种原因不可行怎么办? Vagrant中没有可以解决这个问题的配置吗?此外,它为什么不能“将 .sock 文件存储在 virtualbox 共享文件夹中”?
  • 我会说这对于尝试使用共享文件夹时 vagrant 上的大多数套接字相关问题很有用。如果有人可以提供解决方法,@Agis 的答案会很棒。
猜你喜欢
  • 1970-01-01
  • 2018-11-18
  • 1970-01-01
  • 2014-03-03
  • 1970-01-01
  • 2016-07-16
  • 2016-11-19
  • 1970-01-01
  • 2018-05-24
相关资源
最近更新 更多