gpt4 book ai didi

ruby-on-rails - 薄启动错误 (`start_unix_server' : no unix-domain acceptor (RuntimeError))

转载 作者:行者123 更新时间:2023-12-01 08:29:11 26 4
gpt4 key购买 nike

我在 nginx 上部署了一个 rails 应用程序,使用 capistrano(rails 4、ruby 2.1.2、thin 1.6.2、capistrano 2.1.5)进行瘦身。我通过瘦启动命令开始瘦。并查看此文件 Thin.log 上的一些错误。谁能告诉我如何解决这个问题?

非常感谢!

瘦.yml

 pid: /home/deploy/myapp/pids/thin.pid
port: 3000
timeout: 30
wait: 30
log: log/thin.log
max_conns: 1024
require: []
environment: production
max_persistent_conns: 512
threaded: true
no-epoll: true
daemonize: true
socket: /home/deploy/myapp/sockets/thin.sock
chdir: /home/deploy/myapp/current
address: 0.0.0.0

/etc/nginx/sites-availabel/默认

upstream myapp{
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
server {
listen 80;
server_name _;
character utf-8;


access_log /home/deploy/myapp/log/access.log;
error_log /home/deploy/myapp/log/error.log;
root /home/deploy/myapp/current/public;

location / {
proxy_pass http://127.0.0.1:3000;
}

}

瘦日志

Writing PID to /home/deploy/myapp/pids/thin.pid
Using rack adapter
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on /home/deploy/myapp/sockets/thin.sock, CTRL+C to stop
Exiting!
/home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:528:in `start_unix_server': no unix-domain acceptor (RuntimeError)
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:528:in `start_server'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:548:in `start_unix_domain_server'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/backends/unix_server.rb:19:in `connect'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/backends/base.rb:63:in `block in start'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `call'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/controllers/controller.rb:87:in `start'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/runner.rb:199:in `run_command'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/runner.rb:155:in `run!'
from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/bin/thin:6:in `<top (required)>'
from /home/deploy/.rvm/gems/ruby-2.1.2/bin/thin:23:in `load'
from /home/deploy/.rvm/gems/ruby-2.1.2/bin/thin:23:in `<main>'
from /home/deploy/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
from /home/deploy/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

最佳答案

一般来说:配置 Thin 和 Nginx 一起工作

我刚刚在我的 VPS 上遇到了几乎相同的问题。我不明白的是你的瘦配置结合了端口和套接字。我不知道这是否是个好方法。

但无论如何,这是我的建议:

偏薄

您只需告诉 Thin 使用 /home/deploy/myapp/sockets/thin.sock 套接字。好吧,我们很好。我会为套接字使用另一个目录(比如 /tmp 或您的应用程序的 tmp 目录),但我不是专家,这是您的电话。

在 Nginx 端

如果你想让 Thin 和 Nginx 通信,你必须告诉 Nginx Thin 正在监听这个特定套接字上的传入请求。在这里,在您的 upstream block 中,您告诉 Nginx Thin 正在监听 localhost:3000 上的传入请求。同样,由于您在 Thin conf 中同时使用端口和套接字,我不确定这是否是一个问题(但至少,就 Thin-Nginx 通信而言,这些设置之一对我来说似乎没用被关注到)。如果在同一台机器上同时使用 Nginx 和 Thin,我认为套接字是一种更好的方法,因为它们使通信依赖于文件系统而不是 HTTP 请求,这应该更有效。要告诉 Nginx Thin 正在监听套接字,您必须使用像这样的 upstream block :

upstream myapp {
server unix:/home/deploy/myapp/sockets/thin.sock;
}

从你的 Thin 配置文件来看,这个项目只有一个 Thin 实例,所以你只需要一个 server 行。如果您使用过 2 个 Thin 实例(在您的 Thin yml 配置中使用 servers: 2),那么您会在 nginx 端执行类似的操作:

upstream myapp {
server unix:/home/deploy/myapp/sockets/thin.0.sock;
server unix:/home/deploy/myapp/sockets/thin.1.sock;
}

"没有 unix 域接受器 (RuntimeError)"

至于"no unix-domain acceptor (RuntimeError)"错误,可能是socket目录的权限问题,至少我刚刚遇到这个问题时是这样的现在(不知道为什么,我的 sockets 目录不见了,当我再次创建它时,它必须具有正确的权限才能避免此错误)。所以我想说看看这个;)

关于ruby-on-rails - 薄启动错误 (`start_unix_server' : no unix-domain acceptor (RuntimeError)),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24507225/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com