【问题标题】:Rails server suddenly stopped working with Mysql and couldnt connect sinceRails 服务器突然停止使用 Mysql 并且无法连接,因为
【发布时间】:2015-10-09 12:48:36
【问题描述】:

我正在学习 ruby​​ on rails。正在构建一个小应用程序,服务器已断开连接,不会再次连接。

使用:

rails server

我在 app 目录中。(双重,三重检查...)。

连接到服务器有一段时间工作正常,然后就停止了。

我正在使用 Mysql。

Rails 服务器在我正在开发的其他应用程序上可以正常启动。

这些是我的版本:

root@R://# ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
root@R://# rails -v
Rails 4.2.1

和mysql版本:

+-------------------------+-------------------------+ | Variable_name | Value | +-------------------------+-------------------------+ | innodb_version | 5.5.43 | | protocol_version | 10 | | slave_type_conversions | | | version | 5.5.43-0ubuntu0.14.04.1 | | version_comment | (Ubuntu) | | version_compile_machine | x86_64 | | version_compile_os | debian-linux-gnu | +-------------------------+-------------------------+

这是输出

rails server

root@R://home/ruby/Projects/SempleApp# rails server => Booting WEBrick => Rails 4.2.1 application starting in development on http://localhost:3000 => Runrails 服务器-hfor more startup options => Ctrl-C to shutdown server Exiting

我的 database.yml 文件设置正常,自从服务器连接后我没有更改它。

我重新启动了 Mysql 服务。重启了终端,重启了整台电脑。。这个应用还是连接不上服务器,其他应用可以。。

我被困住了……在任何地方都找不到答案。帮助...

PS- 这是我在这里的第一个Q。希望我提供了正确的信息。

谢谢

完全错误:

root@ruby-man://home/ruby/Projects/TweetrWork# rails server => Booting WEBrick => Rails 4.2.1 application starting in development on @987654321@ => Run rails server -h for more startup options => Ctrl-C to shutdown server Exiting /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in load': /home/ruby/Projects/TweetrWork/config/routes.rb:60: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError) from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:inblock in load' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in load_dependency' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:inload' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:40:in block in load_paths' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:40:ineach' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:40:in load_paths' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:16:inreload!' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:26:in block in updater' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/file_update_checker.rb:75:incall' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/file_update_checker.rb:75:in execute' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:27:inupdater' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:7:in execute_if_updated' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application/finisher.rb:69:inblock in ' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in instance_exec' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:inrun' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:55:in block in run_initializers' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:226:inblock in tsort_each' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:348:in block (2 levels) in each_strongly_connected_component' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:429:ineach_strongly_connected_component_from' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:347:in block in each_strongly_connected_component' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:345:ineach' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:345:in call' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:345:ineach_strongly_connected_component' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:224:in tsort_each' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:203:intsort_each' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:54:in run_initializers' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application.rb:352:ininitialize!' from /home/ruby/Projects/TweetrWork/config/environment.rb:5:in <top (required)>' from /home/ruby/Projects/TweetrWork/config.ru:3:inrequire' from /home/ruby/Projects/TweetrWork/config.ru:3:in block in <main>' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:ininstance_eval' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in initialize' from /home/ruby/Projects/TweetrWork/config.ru:innew' from /home/ruby/Projects/TweetrWork/config.ru:in <main>' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:ineval' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in new_from_string' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:40:inparse_file' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:299:in build_app_and_options_from_config' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:208:inapp' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/server.rb:61:in app' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:336:inwrapped_app' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/server.rb:139:in log_to_stdout' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/server.rb:78:instart' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:80:in block in server' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:intap' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in server' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:inrun_command!' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in <top (required)>' from /home/ruby/Projects/TweetrWork/bin/rails:8:inrequire' from /home/ruby/Projects/TweetrWork/bin/rails:8:in <top (required)>' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/client/rails.rb:28:inload' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/client/rails.rb:28:in call' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/client/command.rb:7:incall' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/client.rb:26:in run' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/bin/spring:48:in' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/binstub.rb:11:in load' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/binstub.rb:11:in' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from /home/ruby/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /home/ruby/Projects/TweetrWork/bin/spring:13:in <top (required)>' from bin/rails:3:inload' from bin/rails:3:in `'

【问题讨论】:

  • 当你rails dbconsole时会发生什么
  • 完美进入控制台..
  • 能否发布运行时遇到的错误rails s
  • 我用完整的错误更新了 Q..
  • TweetrWork/config/routes.rb 文件中您缺少end 关键字,请添加并使用rails s 重新启动

标签: mysql ruby-on-rails


【解决方案1】:

答案就在这里:

4.2.1/lib/active_support/dependencies.rb:268:in load': /home/ruby/Projects/TweetrWork/config/routes.rb:60: syntax error, unexpected end-of-input, **expecting keyword_end (SyntaxError)**

这是您代码中的错字。正如 Prashant4224 所写,在 /home/ruby/Projects/TweetrWork/config/routes.rb 的正确位置添加 end 应该可以解决问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-17
    • 1970-01-01
    • 2013-02-11
    • 2016-03-11
    • 1970-01-01
    • 1970-01-01
    • 2020-11-22
    相关资源
    最近更新 更多