Cómo usar Byebug con un proceso remoto (por ejemplo, pow)
¿Cómo me conecto a una instancia de depuración remota de Byebug (para usar con Pow, etc.)?
2 answers
La respuesta de José fue buena pero confusa en algunas pequeñas maneras. Coloca el inicio del servidor byebug en config/environments/development.rb
, cuando sería mejor en un inicializador. Además, la exportación de la variable de entorno va en .powenv
o .powrc
. Así es como conseguí que funcionara.
En tu gemfile:
gem 'byebug'
En la línea de comandos:
bundle install
Si está usando Pow, agregue lo siguiente a .powenv
:
export BYEBUGPORT=3001
Si está utilizando otros frameworks (por ejemplo, solo foreman
), puede tiene que modificar .env
en su lugar.
if Rails.env.development? and ENV['BYEBUGPORT']
require 'byebug/core'
Byebug.start_server 'localhost', ENV['BYEBUGPORT'].to_i
end
Y finalmente en la línea de comandos:
touch tmp/restart.txt
Una vez que vaya a su sitio pow, el servidor byebug debe iniciarse. En la línea de comandos ahora puede hacer:
[bundle exec] byebug -R localhost:3001
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-10-24 08:18:16
Tuve que reunir información de varias fuentes diferentes para lograr lo anterior, así que pensé en incluir una guía consolidada aquí para conveniencia:
- https://github.com/deivid-rodriguez/byebug/pull/29 ,
- https://github.com/deivid-rodriguez/byebug/pull/36 ,
- https://github.com/deivid-rodriguez/byebug/issues/31
- http://mines.mouldwarp.com/2012/04/pow-guard-and-rdebug-staying-in-web-app.html
Aquí están los pasos:
-
En config/environments/development.po, añádase:
require 'byebug' #set in your .powconfig if ENV['RUBY_DEBUG_PORT'] Byebug.start_server 'localhost', ENV['RUBY_DEBUG_PORT'].to_i else Byebug.start_server 'localhost' end
-
Reiniciar Pow y visitar yourapp.dev
-
Ejecute lo siguiente:
[bundle exec] byebug -R localhost:<port_you_defined_in_pow_config>
Debería ver una conexión correcta a la instancia remota.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-15 18:23:33