.rvm/gems/ruby-2.6.5/gems/puma-4.3.3/lib/puma/binder.rb:328:in 'listen': 地址已在使用 - listen(2) (errno



几天前,我从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

我也尝试了这篇文章中给出的方法:地址已经在使用-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"

看起来您正在端口3000上运行另一个程序。运行lsof -i:3000,并在命令有一些结果时使用kill命令停止它。