RubyMine - Debug Rails App - Unicorn Server - ruby

i am trying to debug rails app - unicorn server.
I've tried following:
1) I tried to start the server on localhost (externally, not with RubyMine) and set some break points. I can see my server when trying to "attach to process". It can attach to process but when i call some REST WebService it won't stop on this method in controller.
2) I tried to run the server from Debugger in RubyMine, the server starts, but when i call some REST WebService it won't stop on this method in controller.
How to debug the Rails App on Mac OS (localhost, unicorn)?
The Rails App ist only API. I want to debug my api calls.

Problem solved:
- i was using pow and it was redirecting to some url and not directly to localhost:3000. Once i converted the requests to use localhost:3000 instead of pow URL xxx.something.test debugger fired up.

I don't have rubymine but this worked for me:
install "pry": https://github.com/pry/pry
start unicorn on your local env:
bundle exec unicorn -c config/unicorn.rb
make sure you're listening to a valid port (in your confic/unicorn.rb):
listen 3000
add
binding.pry
in your code wherever you want a breakpoint
go to:
0.0.0.0:3000

Related

Elixir phoenix debugging leads to interactive shell instead of pry

I've been trying to debug a phoenix application.
To do so I used the following instructions:
- To set a break point: require IEx; IEx.pry
- To start a debugging server: iex -S mix phx.server
The problem comes when starting the server, the above instruction leads me to the elixir interactive shell (iex(1)>) and does not allow the server to run, from here if I execute the code manually it stops in the prys but I was hopping to have the server running and stop whenever a request hit the pry. Is there any solution?
I am currently using earlang 1.20, elixir 1.5 and phoenix 1.3
It is common behavior that the iex -S mix phx.server command opens an IEx shell. It runs the web server on the port configured for the Phoenix endpoint within the respective MIX_ENV simultaneously to that. For each IEx.pry() breakpoint it executes, it should prompt on the command line whether you want to open an IEx shell there.
Check which MIX_ENV your server is running in, e.g. by typing the following in the IEx shell:
Mix.env
And then find the configuration in the files within the config/ directory. The line should look like this:
config :nameofyourapp, Web.Endpoint,
http: [port: 4000],
Maybe something other than 4000 is configured there? Or maybe some other application, or even a previously started instance of your web application already listens on that port and therefore prohibits the debug server from binding on that port? In that case, shutdown other running mix phx.server processes.

configure sinatra as a server

I have written an app in ruby using sinatra. the app works fine and I am testing the post/get request using postman.
Right now I start the app using the command rackup but it starts the server locally on the port 9292. using postman, I send the POST on localhost:9292
I would like to test the app when access from another computer. I expect something using POSTMAN sending a POST on http://182.12.34.1:9292 but I didn't find how to do this.
config.ru
load './app/init.rb'
run Sinatra::Application
Procfile
web: bundle exec unicorn -p $PORT -E $RACK_ENV -c ./config/unicorn.rb
Any idea, how to switch from local test to a server ?
Thansks
The easiest way is to use an existing tool like ngrok or localtunnel.
If you have npm installed, then you can do this in a new terminal:
sudo npm install -g localtunnel
lt --port 9292
It will then give you a URL that you can share. Keep in mind these two things:
The URL is only valid as long as the localtunnel process is running
You still need to have your server running on localhost:9292 for it to work.
Did you perhaps listen to localhost only in the config?
You need to bind the host to 0.0.0.0 otherwise it will only only be available locally...

Rails 4 Not Running Server

When running the command
rails server
instead of the server running, I am getting the following output:
Why is the server not running?
It looks like you're not executing rails server inside a rails app directory.
Use rails new app_name and change directory into that app and run rails server again.

Change Meteor Node-Inspector web-port

I need to change the web-port used by node-inspector when debugging Meteor but it seems to always run on 8080, which is where I need to run the Meteor web app.
I've tried setting the NODE_OPTIONS environment variable before running Meteor:
$ export NODE_OPTIONS=--debug=47977
$ meteor debug --port=8080
[[[[[ ~/.../src ]]]]]
=> Started proxy.
=> Started MongoDB.
Starting your app -
Your application is now paused and ready for debugging!
To debug the server process using a graphical debugging interface,
visit this URL in your web browser:
http://localhost:8080/debug?port=5858
Paused at /.../src/.meteor/local/build/main.js:7
Cannot start the server at 0.0.0.0:8080. Error: listen EADDRINUSE.
There is another process already listening at this address.
Run `node-inspector --web-port={port}` to use a different port.
I've tried running node-inspector separately on a different web port then starting meteor, but meteor always seems to also try starting node-inspector on 8080:
$ node-inspector --web-port=47977 &
[1] 74439
$ Node Inspector v0.5.0
info - socket.io started
Visit http://127.0.0.1:47977/debug?port=5858 to start debugging.
$ meteor debug --port=8080
[[[[[ ~/.../src ]]]]]
=> Started proxy.
=> Started MongoDB.
Starting your app -
Your application is now paused and ready for debugging!
To debug the server process using a graphical debugging interface,
visit this URL in your web browser:
http://localhost:8080/debug?port=5858
Paused at /.../src/.meteor/local/build/main.js:7
Cannot start the server at 0.0.0.0:8080. Error: listen EADDRINUSE.
There is another process already listening at this address.
Run `node-inspector --web-port={port}` to use a different port.
Note, there are 3 ports in play here:
8080 - Web port running Meteor web app.
47977 - Web port I want to run node-inspector web app.
5858 - Port used to communicate between the other 2 processes.
I need Meteor to be running on 8080 but can't seem to stop Meteor starting node-inspector on 8080 too. I've also tried a few other ports for node-inspector but with the same results.
Running on Mac with Meteor 1.2.1
I had the same problem, i've solved by:
in terminal run node-inspector --web-port=47977
and in a new terminal run meteor debug
go to http://127.0.0.1:47977/ws=127.0.0.1:47977&port=5858 to start debugging.

debugging a sinatra app with rubmine

I'm trying to debug a sinatra app using RubyMine. I am using rackup to run the app on localhost and unicorn to run it on remote host. My ruby version is 1.9.3.
I should also note that the "run debug mode icon" is grayed out. I don't know what is missing from the configuration.
What gems do I need? What else do I need to do?
update:
I have run the server process on localhost using rackup -p 9000. In order to start debugging -run rdebug-ide --port 1234 -- rackup and got this message :
Fast Debugger (ruby-debug-ide 0.4.17.beta16, ruby-debug-base 0.10.5.rc1) listens on 127.0.0.1:1234
I still don't understand how to debug using Rubymine. I have opened the browser in http://0.0.0.0:1234 and I don't get any response (it keeps loading)
I run the remote host using unicorn like so :
unicorn -c etc/fin_srv_unicorn.conf -E staging
how shold I set up remote debugging? I have tried also rack and ruby remote.
Tried connection to the remote host and running the service (using the command listed above), and then running the rdebug like so :
rdebug-ide --port 1911 -- $SCRIPT$
where for $SCRIPT$ I have tried app/main.rb staging , unicorn -E staging, unicorn -c etc/fin_srv_unicorn.conf -E staging

Resources