【发布时间】:2020-04-28 08:34:50
【问题描述】:
几天前,我从 Mac 更改为 Linux (Ubuntu),并从我在 GitHub 的团队项目中克隆了 repo。 (在此之前它与 Mac 一起工作)。但是现在,我遇到了这个问题。
我试图通过运行在本地 Unix 套接字 (3000) 上启动服务器
bundle exec puma
但它向我显示了这些错误。
[3217] Puma starting in cluster mode...
[3217] * Version 4.3.3 (ruby 2.6.5-p114), codename: Mysterious Traveller
[3217] * Min threads: 1, max threads: 16
[3217] * Environment: development
[3217] * Process workers: 1
[3217] * Preloading application
Traceback (most recent call last):
13: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'
12: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
11: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/puma:23:in `<main>'
10: from /home/shaun/.rvm/gems/ruby-2.6.5/bin/puma:23:in `load'
9: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/bin/puma:10:in `<top (required)>'
8: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/cli.rb:80:in `run'
7: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/launcher.rb:172:in `run'
6: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/cluster.rb:413:in `run'
5: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/runner.rb:161:in `load_and_bind'
4: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:90:in `parse'
3: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:90:in `each'
2: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:151:in `block in parse'
1: from /home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:328:in `add_unix_listener'
/home/shaun/.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:328:in `listen': Address already in use - listen(2) (Errno::EADDRINUSE)
然后我尝试运行
bundle exec puma -C config/puma.rb -b tcp://127.0.0.1:3001
但是服务器没有运行就立即停止。
[3263] Puma starting in cluster mode...
[3263] * Version 4.3.3 (ruby 2.6.5-p114), codename: Mysterious Traveller
[3263] * Min threads: 1, max threads: 16
[3263] * Environment: development
[3263] * Process workers: 1
[3263] * Preloading application
[3263] * Listening on tcp://127.0.0.1:3001
[3263] Use Ctrl-C to stop
我也试过这篇文章中给出的方法:Address already in use - bind(2) (Errno::EADDRINUSE)
喜欢
lsof -wni tcp:3000
但没有显示任何内容让我终止 Pid 进程。
有人可以帮忙吗?
这些是我正在使用的软件版本:
- Ubuntu 18.04 LTS
- Ruby 2.6.5p114(2019-10-01 修订版 67812)[x86_64-linux]
- 彪马版本 4.3.3
这是 config/puma.rb 中的代码
# vars
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
# Specifies the `environment` that Puma will run in.
environment ENV.fetch("RACK_ENV") { "production" }
# pidfile and state
pidfile "#{shared_dir}/pids/puma.pid"
state_path "#{shared_dir}/pids/puma.state"
# Threads for serving requests
threads 1, 16
# Workers (cpu cores)
workers ENV.fetch("WEB_CONCURRENCY") { 1 }
preload_app!
# Unix socket to for nginix reverse proxy
bind "unix://#{shared_dir}/sockets/puma.sock"
# Port for local server use
port ENV.fetch("PORT") { 3000 }
# Debugging
debug
# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
activate_control_app
rackup "#{app_dir}/config.ru"
【问题讨论】:
-
您是否重新启动计算机并再次尝试?如果是这样,您如何在
config/puma.rb中定义您的收听选项? -
@anothermh 是的,这几天我确实重启了我的电脑几次。这是你要找的线路吗?
port ENV.fetch("PORT") { 3000 } -
app_dir = File.expand_path("../..", __FILE__) shared_dir = "#{app_dir}/shared" environment ENV.fetch("RACK_ENV") { "development" } pidfile "#{shared_dir}/pids/puma.pid" state_path "#{shared_dir}/pids/puma.state" # Threads for serving requests threads 1, 16 workers ENV.fetch("WEB_CONCURRENCY") { 1 } preload_app! bind "unix://#{shared_dir}/sockets/puma.sock" port ENV.fetch("PORT") { 3000 } debug stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true activate_control_app rackup "#{app_dir}/config.ru" -
不要在 cmets 中发布代码。这是一个无法阅读的混乱。您的问题会在您的问题中更新。
-
@anothermh 好的,知道了。谢谢你让我知道。我在上面的问题中更新了它们。非常感谢您的帮助。 :)
标签: ruby rubygems ubuntu-18.04 windows-subsystem-for-linux puma