我正在尝试安装美洲狮宝石,但是当我跑的时候
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) 我有一个Rails 5应用程序,Action Cable用于websocket功能.
在我的开发环境中,一切都按预期工作,浏览器客户端成功连接到Action Cable通道.
在我的生产环境Action Cable中,某些时候正在工作,但突然停止运行,没有任何明显的原因.
如果我在我的开发机器上运行应用程序时更改RAILS_ENV为production正常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.
有没有办法监控美洲狮服务器的状态?最具体地说,它拥有多少繁忙的工作人员以及每个工作人员配置的线程数.最好的是类似于apache的mod_status
我已经将我们的堆栈转换为Rails 4(是的!)
我希望利用线程安全的代码.
美洲狮起床,停止它似乎是一个不同的问题:(
Puma是唯一的多线程导轨吗?
Thin -> EventMachine
Unicorn -> Forking
Puma -> multi-threaded
Mongrel -> don't care
Webbrick -> don't care
Run Code Online (Sandbox Code Playgroud) 我按照本指南记录了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 ?
我通过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) 描述错误
我试图做一个gem install puma和gem 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) 我在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连接?
一般来说:我的配置应该如何看待并发性和性能?
我有一个在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) 我希望使用Puma webserver将我的Rails应用程序部署到Heroku.但是,我不确定所有Gems是否都是线程安全的.阅读所有宝石的源代码对我们来说不是一个可行的选择.
有没有办法自动检查所有Gems的线程安全性?或者,如果执行/检测到线程不安全的代码,Puma是否会抱怨/显示特定的错误日志?