Rails
アプリを4.1.1
から5.1.4
にアップグレードしています。以前はアプリケーションサーバーでwebrickを使用していましたが、Rails 5
はデフォルトサーバーとしてPuma
を使用していますので、インストールしましたがエラーが発生しました。PumaがRails 5で動作しない
のconfig/puma.rb
# Change to match your CPU core count
workers 2
# Min and Max threads per worker
threads 1, 6
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
# Default to production
rails_env = ENV['RAILS_ENV'] || "development"
environment rails_env
# Set up socket location
bind "unix:/home/system/project/shared/sockets/puma.sock"
# bind "unix:#{shared_dir}/sockets/puma.sock"
# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
# Set master PID and state locations
pidfile "#{shared_dir}/pids/puma.pid"
state_path "#{shared_dir}/pids/puma.state"
activate_control_app
on_worker_boot do
require "active_record"
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env])
end
私は、フォルダのルートパスに適切な権限を持つ '共有/ソケット' を作成しました:
drwxrwxrwx 1 system system 4096 Sep 19 10:35 tmp
drwxr-xr-x 1 system system 4096 Sep 19 10:37 sockets
drwxr-xr-x 1 system system 4096 Sep 19 10:51 shared
私はrails s
を実行したり、puma
を実行しようとするとフォアグラウンドモードでは、以下のエラーが表示されます。
[email protected] /home/system/project (rails_upgrade_5 *) $ rails s
=> Booting Puma
=> Rails 5.1.4 application starting in development
=> Run `rails server -h` for more startup options
[28725] Puma starting in cluster mode...
[28725] * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
[28725] * Min threads: 1, max threads: 6
[28725] * Environment: development
[28725] * Process workers: 2
[28725] * Phased restart available
[28725] * Listening on unix:/home/system/project/shared/sockets/puma.sock
Exiting
/home/system/.rvm/gems/[email protected]_5/gems/puma-3.10.0/lib/puma/binder.rb:367:in `initialize': Operation not permitted - connect(2) for /home/system/project/shared/sockets/puma.sock (Errno::EPERM)
from /home/system/.rvm/gems/[email protected]_5/gems/puma-3.10.0/lib/puma/binder.rb:367:in `new'
from /home/system/.rvm/gems/[email protected]_5/gems/puma-3.10.0/lib/puma/binder.rb:367:in `add_unix_listener'
from /home/system/.rvm/gems/[email protected]_5/gems/puma-3.10.0/lib/puma/binder.rb:141:in `block in parse'
from /home/system/.rvm/gems/[email protected]_5/gems/puma-3.10.0/lib/puma/binder.rb:88:in `each'
from /home/system/.rvm/gems/[email protected]_5/gems/puma-3.10.0/lib/puma/binder.rb:88:in `parse'
from /home/system/.rvm/gems/[email protected]_5/gems/puma-3.10.0/lib/puma/cluster.rb:420:in `run'
from /home/system/.rvm/gems/[email protected]_5/gems/puma-3.10.0/lib/puma/launcher.rb:183:in `run'
from /home/system/.rvm/gems/[email protected]_5/gems/puma-3.10.0/lib/rack/handler/puma.rb:69:in `run'
from /home/system/.rvm/gems/[email protected]_5/gems/rack-2.0.3/lib/rack/server.rb:297:in `start'
from /home/system/.rvm/gems/[email protected]_5/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:44:in `start'
from /home/system/.rvm/gems/[email protected]_5/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:135:in `block in perform'
from /home/system/.rvm/gems/[email protected]_5/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `tap'
from /home/system/.rvm/gems/[email protected]_5/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `perform'
from /home/system/.rvm/gems/[email protected]_5/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from /home/system/.rvm/gems/[email protected]_5/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /home/system/.rvm/gems/[email protected]_5/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from /home/system/.rvm/gems/[email protected]_5/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
from /home/system/.rvm/gems/[email protected]_5/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
from /home/system/.rvm/gems/rub[email protected]_5/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>
stackoverflow
にある解決策を試しましたが、うまくいきませんでした。 私が間違っているかどうか教えてください。
私は 'sock'ファイルでそれが必要です。 –
ソックスファイルとはどういう意味ですか? –
私の 'puma.rb'ファイルを確認してください。私は基本的にはnginxで、nginxブロックでは、私は 'sock'ファイルを上流に提供しています。 –