Rails 5.2生产模式下在Apache下启动彪马时出现故障



所以我是Apache的新手。(来自乘客。(我从Capistrano部署,看起来彪马已经装载了。。。

01:21 puma:start
using conf file /var/www/mfta/shared/puma.rb
01 /usr/share/rvm/bin/rvm default do bundle exec puma -C /var/www/mfta/shared/puma.rb --daemon
01 Puma starting in single mode...
01
01 * Version 3.12.1 (ruby 2.6.2-p47), codename: Llamas in Pajamas
01
01 * Min threads: 4, max threads: 16
01
01 * Environment: production
01
01 * Daemonizing...
01

但事实并非如此。

Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

如果我运行"bundle exec puma-e production">。。。它工作得很好,但结果是"监听"而不是"守护进程">

Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.2-p47), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: production
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

这是我的deploy.rb:

set :stage,           :production
set :deploy_via,      :remote_cache
set :puma_bind,       "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state,      "#{shared_path}/tmp/pids/puma.state"
set :puma_pid,        "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log,  "#{release_path}/log/puma.access.log"
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true
namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'puma:start'
end
end

这是来自我的apache2虚拟主机文件:

<VirtualHost *:80>
NameVirtualHost 99.99.99.99
ServerName myapp.org
DocumentRoot /var/www/myapp/current/public
ServerSignature Off
ProxyRequests Off
<Proxy *>
Order Allow,Deny
Allow from all
</Proxy>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
ProxyVia On
</VirtualHost>

也许我应该告诉Capistrano或Puma用Apache做一些额外的事情?将Apache2连接到彪马精灵还有其他步骤吗?

正如我所怀疑的。。。答案就在彪马牌上。

puma.rb

set :puma_bind,       "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"

这是你将用于NGINX的设置,我相信。。。如果您使用的是Apache,那么它应该与虚拟主机ProxyPass中的任何内容相匹配。在这种情况下:

ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/

因此,您的deploy.rb应该绑定以下内容:

set :puma_bind,       "tcp://0.0.0.0:3000"

因此,您的puma.bind文件变为:

bind 'tcp://0.0.0.0:3000'

这是默认值。或者你选择的任何东西。

我相信有十亿种方法可以做到这一点。。。但到目前为止,这才是我最终成功的地方。

最新更新