无法运行localhost:3000:呈现空白页面

时间:2016-04-07 14:21:00

标签: ruby-on-rails puma

我正在使用Rails 4.2.6和Ruby 2.3.0以及Puma 3.3.0 在过去的几天里,我运行了一些软件包更新,在rails之后,同一个网址localhost:3000的所有浏览器都呈现相同的空白页面。 这与我正在玩的所有6-7个应用程序一致。 但是当部署到Heroku时,所有人都在“生产”中工作。 似乎只是与我的开发环境相关的问题。

不知道如何解决这个问题。任何帮助都感激不尽。如果无法对我正在开发的代码运行单元测试,则无法继续开发。

然而,当我使用另一个端口时,一切正常。例如,当使用rails s -p 3001或port 3002命令启动应用服务器时,使用URL localhost:3001或localhost:3002在任何浏览器中运行应用程序都没有问题。

我的3000端口或Puma或两者有什么问题?

1 个答案:

答案 0 :(得分:12)

它可能发生在开发中的本地,而不是“prod”,即Heroku由于停止Puma时的错误。有些时候,由于以下原因,某些进程未被杀死:

levi-test-01 liviu-mac $ rails s
=> Booting Puma
=> Rails 4.2.6 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[4589] Puma starting in cluster mode...
[4589] * Version 3.3.0 (ruby 2.3.0-p0), codename: Jovial Platypus
[4589] * Min threads: 5, max threads: 5
[4589] * Environment: development
[4589] * Process workers: 2
[4589] * Preloading application
[4589] * Listening on tcp://localhost:3000
[4589] Use Ctrl-C to stop
[4589] - Worker 1 (pid: 4603) booted, phase: 0
[4589] - Worker 0 (pid: 4602) booted, phase: 0
^C[4589] - Gracefully shutting down workers...
/Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/server.rb:355:in `delete': No such file or directory @ unlink_internal - /Users/liviu-mac/ror/levi-test-01/tmp/pids/server.pid (Errno::ENOENT)
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/server.rb:355:in `block in write_pid'
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puma-3.3.0/lib/puma/cluster.rb:120:in `fork'
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puma-3.3.0/lib/puma/cluster.rb:120:in `block in spawn_workers'
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puma-3.3.0/lib/puma/cluster.rb:116:in `times'
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puma-3.3.0/lib/puma/cluster.rb:116:in `spawn_workers'
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puma-3.3.0/lib/puma/cluster.rb:418:in `run'
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puma-3.3.0/lib/puma/launcher.rb:172:in `run'
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puma-3.3.0/lib/rack/handler/puma.rb:51:in `run'
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/server.rb:286:in `start'
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/server.rb:80:in `start'
    from /Users/liviu-mac/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:80:in `block in server'

运行如下命令:

levi-test-01 liviu-mac $ lsof -i :3000

使用port 3000列出所有剩余流程。

这样的命令
levi-test-01 liviu-mac $ kill -9 PID

解决了这个问题。