标签: puma

无法在Ruby on Rails上安装Puma gem

我正在尝试安装美洲狮宝石,但是当我跑的时候

gem install puma
Run Code Online (Sandbox Code Playgroud)

我收到此错误消息:

Temporarily enhancing PATH to include DevKit
Building native extensions.  This could take a while...
ERROR:  Error installing puma:
        ERROR: Failed to build gem native extension.

    C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile

make                                                
generating puma_http11-i386-mingw32.def                              
compiling http11_parser.c       
ext/http11/http11_parser.rl: In function 'puma_parser_execute':  
ext/http11/http11_parser.rl:111:3: warning: comparison between signed and unsigned integer   expressions    
compiling io_buffer.c   
io_buffer.c: In function 'buf_to_str':             
io_buffer.c:119:3: warning: pointer targets in passing argument 1 of 'rb_str_new'      differ in signedness             
c:/Ruby193/include/ruby-1.9.1/ruby/intern.h:653:7: note: expected 'const char *' but argument is …
Run Code Online (Sandbox Code Playgroud)

rubygems ruby-on-rails puma ruby-on-rails-4

23
推荐指数
4
解决办法
2万
查看次数

ActionCable不再在生产环境中工作

我有一个Rails 5应用程序,Action Cable用于websocket功能.

在我的开发环境中,一切都按预期工作,浏览器客户端成功连接到Action Cable通道.

在我的生产环境Action Cable中,某些时候正在工作,但突然停止运行,没有任何明显的原因.

如果我在我的开发机器上运行应用程序时更改RAILS_ENVproduction正常Action Cable工作.在实际的生产机器上运行应用程序时似乎有些不同,尽管基本环境是相同的.

我在Chrome控制台中看到的具体错误:

mydomain.com/:1 WebSocket connection to 'wss://mydomain.com/cable' failed: WebSocket is closed before the connection is established.我在其他浏览器中遇到类似的错误,因此它似乎与浏览器无关.我在测试时禁用了任何广告拦截器以确保它们不会干扰.

Development.rb ENV相关设置:

config.action_cable.url = "ws://localhost:#{port}/cable"
Run Code Online (Sandbox Code Playgroud)

Production.rb ENV相关设置:

hostname = ENV.fetch('HOSTNAME')
  port = ENV.fetch('PORT')
  base_url = "#{hostname}:#{port}"

  config.action_cable.url = "wss://#{hostname}/cable"
  config.action_cable.allowed_request_origins = ["https://#{base_url}", "https://#{hostname}"]
Run Code Online (Sandbox Code Playgroud)

Puma用作网络服务器.Web服务器提供安装了有效证书的SSL连接.在生产机器上,Puma在端口上为应用程序提供服务,3000但这会转发到443路由器中的端口.

在我的开发机器和生产中运行应用程序的唯一显着区别是使用生产SSL.

ssl ruby-on-rails websocket puma actioncable

23
推荐指数
1
解决办法
2932
查看次数

如何监控puma服务器?

有没有办法监控美洲狮服务器的状态?最具体地说,它拥有多少繁忙的工作人员以及每个工作人员配置的线程数.最好的是类似于apache的mod_status

ruby-on-rails puma

22
推荐指数
1
解决办法
9141
查看次数

是puma唯一的多线程导轨4 http服务器?

我已经将我们的堆栈转换为Rails 4(是的!)

我希望利用线程安全的代码.

美洲狮起床,停止它似乎是一个不同的问题:(

Puma是唯一的多线程导轨吗?

Thin -> EventMachine
Unicorn -> Forking
Puma -> multi-threaded

Mongrel -> don't care
Webbrick -> don't care
Run Code Online (Sandbox Code Playgroud)

multithreading ruby-on-rails thin puma ruby-on-rails-4

21
推荐指数
1
解决办法
9276
查看次数

我如何使用puma的配置文件?

我按照本指南记录了puma.rb存储在app的config目录中的文件.

该指南有点夸张,但这是我假设puma.rb文件的作用.而不是像这样运行疯狂的命令来让puma在指定的套接字上运行:

bundle exec puma -e production -b unix:///var/run/my_app.sock
Run Code Online (Sandbox Code Playgroud)

您可以在文件中指定端口,pid,会话和其他参数,puma.rb如下所示:

rails_env = ENV['RAILS_ENV'] || 'production'

threads 4,4

bind  "/home/starkers/Documents/alpha/tmp/socket"
pidfile "/home/starkers/Documents/alpha/tmp/pid"
state_path "/home/starkers/Documents/alpha/tmp/state"

activate_control_app
Run Code Online (Sandbox Code Playgroud)

然后你可以进入应用程序的root并运行一个简单的命令

"彪马"

puma.rb遵循设定的参数.不幸的是,这似乎对我不起作用.

至少,我在puma一个小测试应用程序的根目录内运行,没有.sock文件出现, /home/starkers/Documents/alpha/tmp/sockets所以这意味着它不起作用?

我该如何工作?我在本地开发机器上,所以可能会以某种方式导致此错误?运行时是否需要传入参数

puma

ruby-on-rails puma

20
推荐指数
3
解决办法
3万
查看次数

PG :: TRDeadlockDetected:ERROR:检测到死锁

我通过bundle exec pumactl -F config/puma.rb phased-restart什么工作正常重启8个美洲狮工人.现在我收到越来越多的postgres错误:

PG::TRDeadlockDetected: ERROR:  deadlock detected
Run Code Online (Sandbox Code Playgroud)

我发现大约有50个闲置的postgres进程在运行:

postgres: myapp myapp_production 127.0.0.1(59950) idle
postgres: myapp myapp_production 127.0.0.1(60141) idle
...
Run Code Online (Sandbox Code Playgroud)

当我跑步时,它们消失了bundle exec pumactl -F config/puma.rb stop.启动应用程序后bundle exec pumactl -F config/puma.rb start,我得到了16个空闲进程.(在我看来,太多了.)

如何更好地管理这些流程?谢谢你的帮助!


更新

我的puma.rb:

environment 'production'
daemonize true

pidfile 'tmp/pids/puma.pid'
state_path 'tmp/pids/puma.state'

threads 0, 1
bind 'tcp://0.0.0.0:3010'

workers 8

quiet
Run Code Online (Sandbox Code Playgroud)

ruby postgresql ruby-on-rails idle-processing puma

19
推荐指数
1
解决办法
9694
查看次数

Thin 和 Puma 因类似问题而失败 - 错误:无法使用 OpenSSL@1.1 在 Mac 上构建 gem 本机扩展

描述错误 我试图做一个gem install pumagem install thin并得到一个错误。

我有一台全新的 Mac 正在设置:MacOS Catalina 10.15.6 (19G73)

我已经发现任何版本 <= 4.2.1 在我的计算机上都可以正常工作我正在使用asdf版本管理器

  • 作品: gem install puma -v '4.2.1'
  • 失败:gem install puma -v '4.3.0'gem install pumad

彪马的错误

我已经尝试了这些命令中的每一个来让它工作

gem install puma

gem install puma -v '4.3.0'  --  --with-ldflags=-L/usr/local/opt/openssl@1.1/lib  --with-cppflags=-I/usr/local/opt/openssl@1.1/include

gem install puma -v '4.3.0'  --  --with-ldflags=-L/usr/local/opt/openssl@1.1/lib  --with-cppflags=-I/usr/local/opt/openssl@1.1/include --with-opt-dir=/usr/local/opt/openssl@1.1
Run Code Online (Sandbox Code Playgroud)
Building native extensions. This could take a while...
ERROR:  Error installing puma:
    ERROR: Failed to build gem native extension. …
Run Code Online (Sandbox Code Playgroud)

ruby macos thin puma macos-catalina

19
推荐指数
1
解决办法
3722
查看次数

Heroku上的Puma Cluster配置

我在RoR4 Heroku应用程序上配置Puma(多线程+多核服务器)需要一些帮助.Heroku上的文档并不是最新的.我遵循了这个:配置的并发和数据库连接,没有提到集群的配置,所以我不得不同时使用这两种类型(线程和多核).

我目前的配置:

./Procfile

web: bundle exec puma -p $PORT -C config/puma.rb
Run Code Online (Sandbox Code Playgroud)

./config/puma.rb

environment production
threads 0,16

workers 4
preload_app!

on_worker_boot do
  ActiveRecord::Base.connection_pool.disconnect!

  ActiveSupport.on_load(:active_record) do
    config = Rails.application.config.database_configuration[Rails.env]
    config['reaping_frequency'] = ENV['DB_REAP_FREQ'] || 10 # seconds
    config['pool']              = ENV['DB_POOL'] || 5
    ActiveRecord::Base.establish_connection
  end
end
Run Code Online (Sandbox Code Playgroud)

问题:

a)我是否需要像Unicorn一样的before_fork/after_fork配置,因为群集工作者是分叉的?
b)如何根据我的应用程序调整我的线程数 - 将它放下的原因是什么?/在什么情况下它会有所作为?是不是已经优化了0:16?
c)Heroku数据库允许500个连接.根据线程,工作线程和动态计数,DB_POOL的值是多少? - 并行工作时,每个dyno的每个工作线程的每个线程是否都需要唯一的DB连接?

一般来说:我的配置应该如何看待并发性和性能?

postgresql ruby-on-rails heroku unicorn puma

18
推荐指数
1
解决办法
6483
查看次数

我的应用程序不断创建数据库连接,我如何追踪原因?

我有一个在Heroku上运行的Ruby on Rails应用程序.我一直在日志中收到这些消息:

2015-05-05T16:11:14Z app[postgres.27102]: [AQUA] connection received: host=xx.xxx.xx.26 port=60278
2015-05-05T16:11:14Z app[postgres.27102]: [AQUA] connection authorized: user=postgres database=somedb
2015-05-05T16:11:14Z app[postgres.27103]: [AQUA] connection received: host=xx.xxx.xx.26 port=60291
2015-05-05T16:11:14Z app[postgres.27103]: [AQUA] connection authorized: user=postgres database=postgres
2015-05-05T16:11:18Z app[postgres.27104]: [AQUA] connection received: host=xx.xxx.x.166 port=54180
2015-05-05T16:11:18Z app[postgres.27104]: [AQUA] connection authorized: user=postgres database=somedb
2015-05-05T16:11:23Z app[postgres.27105]: [AQUA] connection received: host=xx.xxx.x.166 port=55488
2015-05-05T16:11:23Z app[postgres.27105]: [AQUA] connection authorized: user=postgres database=somedb
2015-05-05T16:11:28Z app[postgres.27106]: [AQUA] connection received: host=xx.xxx.x.166 port=56774
2015-05-05T16:11:28Z app[postgres.27106]: [AQUA] connection authorized: user=postgres database=somedb
2015-05-05T16:11:28Z app[postgres.27107]: [AQUA] connection received: host=xx.xxx.x.166 port=56854 …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails heroku puma rails-activerecord

18
推荐指数
1
解决办法
441
查看次数

如何检查Rails应用程序的Puma线程安全性

我希望使用Puma webserver将我的Rails应用程序部署到Heroku.但是,我不确定所有Gems是否都是线程安全的.阅读所有宝石的源代码对我们来说不是一个可行的选择.

有没有办法自动检查所有Gems的线程安全性?或者,如果执行/检测到线程不安全的代码,Puma是否会抱怨/显示特定的错误日志?

ruby multithreading ruby-on-rails heroku puma

18
推荐指数
1
解决办法
2953
查看次数