Is there a way to setup a rails server so that you can connect with a remote byebug server and debug easily? I've done this in the past by setting up byebug and then enabling a rails bind on 0.0.0.0 and setting a VIRTUAL_PORT=3000 but I was wondering if there were other easier ways to debug an already running container. I looked into https://docs.docker.com/engine/reference/commandline/attach/ but wasn't able to get it setup properly.
See this previous answer. Do note that running your services in detached mode isn't necessary. Also when attaching to the rails container, it'll appear as if nothing happened in your terminal until you make a request to the rails application.
Related
Recently I migrated my workspace from the old Cloud9 to AWS Cloud9. Now I can no longer run my application. I'm hoping somebody on Stack Overflow might have an idea what the problem is because AWS' help forums and documentations skip past the parts I'm missing.
The "Run" button tries run the last file that I was viewing and editing, rather than my application as a whole.
So I try to start it running in the terminal with "rails s -b $IP -p $PORT". I get this line:
Listening on tcp://127.0.0.1:8080
So the program should be running, right? But the green "Run" button is now disabled, and I don't get the spinning icon in my terminal window that I used to get with old Cloud9.
Next I try getting the application's url from the "Share" menu, which is:
18.212.63.5
When I try to navigate to this url in another window, I get an error
ERR_CONNECTION_TIMED_OUT
When I try to "Preview Running Application" with the IDE, I get the error
66af0558a4b44f8bb019cb5628f6b28f.vfs.cloud9.us-east-1.amazonaws.com refused to connect.
In related news, I'm highly frustrated with AWS for a lot of other reasons. Should I consider switching to a different IDE? Or keep trying to learn this one?
Thank you in advance for any insight.
See also https://forums.aws.amazon.com/thread.jspa?messageID=899522, which provides a set of diagnostic commands that you can run from a terminal session in the AWS Cloud9 IDE for your development environment that can output the incoming traffic rules for the environment's associated Amazon EC2 instance's security group and network ACL. These traffic rules need to allow incoming traffic for the correct protocol and port.
I had what I believe was a similar problem. The preview won't show if the app is being served over http, rather than https:
https://docs.aws.amazon.com/cloud9/latest/user-guide/troubleshooting.html#troubleshooting-app-preview-http
A simple workaround here is just to remove the 's' from the amazonaws.com URL listed in the 'refused to connect' error, and then press the button to preview the application in a browser tab.
Also note that on AWS C9 you shouldn't need
rails s -b $IP -p $PORT
It should usually be enough to do
rails server
(though check that, for example, your puma.rb file is set to run on port 8080 rather than 3000)
I am using Aptana Studio 3 for development of ROR apps. I used run server command and it showed you can access your app on {http//0.0.0.0:3000/}, but when I try to access this URL, it tells me to check your Internet connection. I tried several other ports also but it is not working. I have created/modified the files necessary and migrated the database successfully too. Appreciate any help in running the app over the browser. I am currently using WeBrick Server.
so, in your title you say "on server". what does that mean? when you are running it on a different machine than your own, you need to use the address of that machine or it's domain name. keep in mind that firewall rules might prevent any connection to that server.
when you are ON the machine, via ssh for example, you can try calling the then "local" rails instance with curl http://localhost:3000/ to verify that it is running.
I'm very new with Rails and I've installed Vagrant to run the Rails server. I've started the server and am able to load localhost:3000, now I don't know where to go. The command line is blank and I read that I should type in "script/console", but all I can really do is ctrl-C or -d.
When I tried to run Vagrant in a separate Window with "vagrant up" it says I need to do "Vagrant init"
Where do I go from here so that I can start going through my tutorials/start developing?
This screencast from RailsCasts should get you started. Some of the suggestions are a bit out-dated but by reading the show notes and comments, you should be able to get up and running. From there you can modify.
While getting Rails set up initially with Vagrant will be work, it's an incredibly handy tool to have experience with. It becomes even more useful when you incorporate a provisioning tool like Puppet.
In your terminal if you are running the webrick server via rails server you either need to background it or open a new terminal to get your shell prompt back. If you ctrl-C out of it you will kill the server. Keep in mind, the webrick server should only be used for local development. It's not a production level web server. See the Rails Getting Started guide for more details.
If you are going to run your rails server in a Vagrant VM, you'll need to configure the port forward in your Vagrantfile so you can access from your host machine.
config.vm.forward_port 3000, 9080
There error you are seeing would be from you running vagrant up in a directory that doesn't contain a Vagrantfile.
I have one Rails instance and another Node.js instance. The plan is to publish information from the Rails project using Redis's pubsub and subscribe by the Node.js program. The node.js program will publish the information to other clients through web sockets (or long polls).
The whole thing is working perfectly while deployed in combination of remote linux machines. On Heroku, Redis To Go is added as an add-on with the Rails instance. Redis can be connected and working fine from this instance.
But I am not getting how to reach to this Redis add-on from the Node.js instance. I've added REDISTOGO_URL from the environment of Rails instance to the environment of Node.js, but it's not working. Sample errors I'm getting (from logs and REPL) are
redis.set("a","b");
==> Error: Connection in pub/sub mode, only pub/sub commands may be used
redis.psubscribe('*');
==> false
Can somebody please show me a way how to accomplish this?
Yes, all you have to do is set the heroku config value similar to:
'heroku config:add REDISTOGO_URL=[your redis togo url]'
Heroku will then add your config var and restart your app.
You can check to make sure it's added correctly by doing a 'heroku config' on both repositories and comparing them.
I have a Rails (2.3.8) application that will need to start and maintain a SSH tunnel whenever the application is started using 'script/server' or when started using Passenger. When script/server is ^C'd or the Passenger instance is shut down the SSH tunnel should be destroyed.
I do not want the tunnel to be started when I run 'script/console' - so using config/environment.rb doesn't look like a good option.
As such, I don't want the tunnel to be backgrounded - I want it to be attached and owned by the ruby process, and I only want one tunnel per server.
The tunnel itself will most likely be started by running SSH directly, but if there's a simple way to do it using the SSH libraries I'll use that instead.
Is there a way to do this in Rails? I can think of a way to do it using config/environment.rb using a series of lock files and other bits of messing around, but I was hoping for some sort of :on_server_start and :on_server_exit hook.
--
For the curious, I need to do this as the Rails application is running in location A and will receive updates from a series of services in location B. Location B, however, does not have a direct route to location A. I will be starting a SSH tunnel from the application to a machine in location B and the services in location B will send updates to that machine instead.
Managed to solve this one using config/environments/*.rb and a quick fork hack. See gist: http://gist.github.com/466267
So, it'll be run if you use RAILS_ENV=production but not for test/development.