。rvm / gems / ruby -2.6.5 / gems / puma-4.3.3 / lib / puma / binder.rb:328:在`listen'中:地址已在使用中-listen(2)( Errno :: EADDRINUSE)

问题描述 投票:1回答:1

我几天前已经从Mac更改为Linux(Ubuntu),我从GitHub的团队项目中克隆了该存储库。 (它在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]
  • Puma版本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"

我几天前已经从Mac更改为Linux(Ubuntu),我从GitHub的团队项目中克隆了该存储库。 (它在Mac之前就可以使用)。但是现在,我遇到了这个问题。我正在尝试...

ruby rubygems ubuntu-18.04 windows-subsystem-for-linux puma
1个回答
0
投票

似乎您正在端口3000上运行另一个程序。运行lsof -i:3000,并在命令产生某些结果时使用kill命令将其停止。

© www.soinside.com 2019 - 2024. All rights reserved.