我正在尝试使用Puma Web服务器部署Rails应用程序.当尝试使用配置文件启动Puma服务器时,bundle exec puma -C config/puma.rb
我收到一个错误,表明该地址已被使用.
有人知道如何解决这个问题吗?
bundle exec puma -C config/puma.rb
[23699] Puma starting in cluster mode...
[23699] * Version 2.11.3 (ruby 2.0.0-p353), codename: Intrepid Squirrel
[23699] * Min threads: 5, max threads: 5
[23699] * Environment: development
[23699] * Process workers: 2
[23699] * Preloading application
Jdbc-MySQL is only for use with JRuby
[23699] * Listening on tcp://0.0.0.0:3000
/.rvm/gems/ruby-2.0.0-p353/gems/puma-2.11.3/lib/puma/binder.rb:210:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
from /.rvm/gems/ruby-2.0.0-p353/gems/puma-2.11.3/lib/puma/binder.rb:210:in `new'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p353/gems/puma-2.11.3/lib/puma/binder.rb:210:in `add_tcp_listener'
from /.rvm/gems/ruby-2.0.0-p353/gems/puma-2.11.3/lib/puma/binder.rb:96:in `block …
Run Code Online (Sandbox Code Playgroud) 我将Puma作为上游应用服务器运行,将Riak作为后台数据库集群运行.当我发送一个请求map - 减少大约25K用户的数据块并将其从Riak返回给应用程序时,我在Nginx日志中收到错误:
上游超时(110:连接超时),同时从上游读取响应头
如果我在没有nginx代理的情况下直接查询我的上游,使用相同的请求,我会得到所需的数据.
一旦放入代理,就会发生Nginx超时.
**nginx.conf**
http {
keepalive_timeout 10m;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
include /etc/nginx/sites-enabled/*.conf;
}
**virtual host conf**
upstream ss_api {
server 127.0.0.1:3000 max_fails=0 fail_timeout=600;
}
server {
listen 81;
server_name xxxxx.com; # change to match your URL
location / {
# match the name of upstream directive which is defined above
proxy_pass http://ss_api;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache cloud;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 …
Run Code Online (Sandbox Code Playgroud) 我正在我的 Windows 10 机器上使用 WSL2/Ubuntu 开发一个 rails 应用程序,这很棒!问题是我无法从同一网络中的另一台计算机连接到我的服务器。
为了更清楚,我在 localhost:3000 上运行 Puma 服务器
我尝试了以下方法:
rails s -b 172.26.208.1 -p 3000
到目前为止,以上都没有奏效......我想做的是:
至少有什么我遗漏的吗?(以及对 VScode 部分的任何评论将不胜感激)
在heroku dyno的背景下,美洲狮工人和美洲狮线程有什么区别?
我所知道的(如果我错了,请纠正我):
精简不是并发的,因此Web进程一次只能执行一个请求
在独角兽中,我知道我可以在一个进程中有几个unicorn worker来添加并发性.
但在美洲狮有线程和工人..在美洲狮过程中,工人不是一个线程吗?
我可以在Heroku中使用更多的worker/threads来添加web并发吗?
我正在使用Rails,Puma,Capistrano3.我也安装了宝石capistrano3-puma
.我和Puma Jungle一起创办了Puma https://github.com/puma/puma/tree/master/tools/jungle/upstart
如何在部署期间重新启动Puma?
我试图服务于多个请求,同时在轨道4,这是我能够用做得很轻松config.threadsafe!
,并Puma
在Rails 3中.
说我有这个控制器
class ConcurrentController < ApplicationController
def index
sleep 10000
end
def show
end
end
Run Code Online (Sandbox Code Playgroud)
我以前能够开始使用puma puma -t 2:16 -p 3000
(最少2个线程)然后点击index
然后show
仍然可以show
正确渲染.
在Rails 4中,如果我尝试做同样的事情,Puma现在会锁定index
请求并且show
永远不会被渲染.当我点击Ctrl-C
服务器时,Puma给了我这个错误:
Rack app error: #<ThreadError: Attempt to unlock a mutex which is locked by another thread>
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么来获得并发使用Rails 4?config.threadsafe!
应该是不需要的(即使我尝试也没有区别)
通常,当你运行rails server
它时,启动Webrick.如果您安装'thin'宝石,那么'thin'会启动.我想用'puma'服务器做同样的事情.
我看到start
railties(lib/rails/commands)中的命令调用super,但我找不到'super'的各种选项.我还在'thin'中回顾了许多对Rails的引用.
我从2008年10月发现了一个名为"添加对脚本/服务器的精简支持.#488 [Bob Klosinski]"的Changelog条目,但该代码区域自该提交后发生了重大变化(a93ea88c0623b4f65af98c0eb55924c335bb3ac1).
如果有人可以将我引导到正确的代码部分,那将非常有帮助.
我在安装puma gem时遇到以下错误
$ gem install puma Fetching: puma-2.11.2.gem (100%) Building native extensions. This could take a while... ERROR: Error installing puma: ERROR: Failed to build gem native extension. ruby extconf.rb checking for BIO_read() in -lcrypto... no checking for BIO_read() in -llibeay32... no *** extconf.rb failed ***
我有一个生产中的rails应用程序,我前几天部署了一些更改.突然间我现在ActiveRecord::ConnectionTimeoutError: could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)
每天多次得到错误并且必须重新启动puma来解决问题.
我完全不知道是什么导致了这一点.我没有更改我的服务器上的任何内容,我所做的更改非常简单(添加到视图并添加到控制器方法).
我在日志文件中看不到任何东西.
我正在使用rails 4.1.4和ruby 2.0.0p481
有关为什么我的连接填满的任何想法?我的连接池设置为10,我使用默认的puma配置.
这是一个堆栈跟踪:
ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)):
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `block in wait_poll'
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `loop'
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `wait_poll'
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:136:in `block in poll'
/usr/local/rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:146:in `synchronize'
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:134:in `poll'
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:418:in `acquire_connection'
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/usr/local/rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in …
Run Code Online (Sandbox Code Playgroud) 任何人都可以解释每个并发方法的瓶颈是什么?
像Unicorn(基于进程)和Puma(基于线程)的服务器.
每种方法都更喜欢CPU内核吗?线程?或者只是时钟速度?还是特殊的组合?
如何确定使用专用服务器时所需的最佳CPU特性?
如何确定Unicorn情况下的最佳工人数量,或者在Puma的情况下确定线程数量?
puma ×10
nginx ×2
ruby ×2
airbrake ×1
capistrano3 ×1
concurrency ×1
deployment ×1
heroku ×1
mysql ×1
timeout ×1
unicorn ×1
windows-subsystem-for-linux ×1
wsl-2 ×1