Rails Byebug没有停止申请

时间:2015-07-28 06:50:59

标签: ruby-on-rails ruby byebug

我想使用byebug调试我的应用程序,但应用程序永远不会停止,尽管我已将byebug放入我的代码中。这是我的Gemfile。

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console

  gem 'byebug', '~> 5.0.0'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

end

我把byebug放在我的一个控制器中。

def edit
  byebug
  present Ingredient::Update
end

我已在我的development.rb中将所有请求发送到本地。我已经重启了服务器几次。

config.consider_all_requests_local       = true

以下是byebug仅打印第一条跟踪然后应用程序继续执行下一行的示例堆栈跟踪。

web_1 | [43, 52] in /recipe/app/controllers/ingredients_controller.rb
web_1 |    43:   def update
web_1 |    44:     run Ingredient::Update do |op|
web_1 |    45:       return redirect_to op.model
web_1 |    46:     end
web_1 |    47:     byebug
web_1 | => 48:     render action: :edit
web_1 |    49:   end
web_1 |    50:
web_1 |    51:   # DELETE /ingredients/1
web_1 |    52:   # DELETE /ingredients/1.json
web_1 | (byebug)   Rendered ingredients/edit.haml within layouts/application (264.1ms)
web_1 |   Rendered layouts/_navigation.haml (45.0ms)
web_1 | Completed 200 OK in 2827ms (Views: 2764.0ms | ActiveRecord: 3.9ms)
web_1 |
web_1 |
web_1 | Started GET "/assets/application.self-1ca8529ef221ef9dba25e835f258c4e62f2f49bce400273a67e63d7d73be28ba.css?body=1" for 192.168.59.3 at 2015-07-28 06:46:00 +0000

有什么想法吗? 的更新 我在我的Rails应用程序中使用docker-compose和docker。

3 个答案:

答案 0 :(得分:65)

docker-composebyebug结合使用时,需要添加此内容才能使其正常运行。找到this blog post

将此添加到docker-compose.yml

web:
  ...
  stdin_open: true
  tty: true

然后在deamonized模式下运行docker-compose并使用docker连接到web容器:

docker-compose up -d
docker attach myappname_web_1

答案 1 :(得分:4)

启用调试器模式:

docker-compose run --service-ports web

请参阅此blog post

答案 2 :(得分:0)

我在同步文件更改(例如添加byebug)时遇到问题,发现在卷定义中添加consistent有帮助:

  volumes:
    - .:/usr/src/app:consistent