"Rails s" has abruptly stopped working - ruby-on-rails

I was getting a bit frustrated with a project I have been working on for the past few days, so I decided to make a little blog for fun (and practice). I created the new rails application and tried to boot it up with “rails s”, but it didn’t work. Confused, I went back to my last project, started the server there, went to localhost:3000 like I have been for the past 2 months, but then ran into the same issue. It had been working 5 minutes earlier, but now neither it, nor any other projects will start.
Here is what I see in the command prompt:

C:\Users\mathi_000\Desktop\fPen\rails s
DL is deprecated, please use Fiddle
=> Booting WEBrick 
=> Rails 4.1.8 application starting in development on http://0.0.0.0:3000
=> Run ‘rails server –h’ for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider
using 127.0.0.1 (--binding option)
When I go to localhost:3000, I am met with the "This page can't be displayed" message. Hopefully one of you can tell me what I screwed up! I am still in the process of learning, but this is obviously a rather large hindrance.

There's not much to go on here, but give my standard solution to these sorts of problems a go: spring stop then try again.

Related

Aptana Studio: A server is already running error

Sometimes when I boot up my computer then open up Aptana Studio for Rails, then try to start my server, I get the following error...
=> Booting WEBrick
=> Rails 3.2.11 application starting in development on http://localhost:3000
=> Call with -d to detach
A server is already running. Check C:/Users/bob/bob_rails_demo/Course_Stats/tmp/pids/server.pid.
=> Ctrl-C to shutdown server
Exiting
When I check that file metioned, I open the file and all it says inside the file is ...
512
Is there a fix for this? I don't see anything else running in task manager. BTW I am running rails 3.2.11 w/ Windows 7.
I have the same problem too, and it didn't happen before, so i believe it is some kind of bug. What I do to solve it is simply delete the server.pid at C:[pathToApp]\tmp\server.pid file before starting my server.
It is saying that PID (process id) 512 is running the server.
Go to Start -> then type taskmgr.exe. Then, go to the processes tab and look for that process and kill it. It might be a bug that it does not close the server correctly on exit.

Rails 3.2 PrivatePub in production faye.js not found

I'm having an issue with a gem called private_pub that uses a faye gem and thin server.
This all works fine in development, but on the server I can get everything started up fine but on the page where I'm using private_pub I get an error in the js console (chrome) that says
GET http://myapp.example.com/faye.js 406 (Not Acceptable)
and when I view http://myapp.example.com/faye.js in the browser (url changed) I get an empty screen where in development it displays all the js code. Also I can see in chrome's developer tools I can see in development the type is "Pending" and in production I'm seeing it passed as "text/html"
I've googled and googled and have come up with exactly nothing. Can anyone point me in the right direction.
Is there some special mime-type that is being passed here that I need to configure apache or rails to accept?
Thank you in advance
HAZZAH!
I figured it out.
I jumped through all kinds of hoops and am not 100% sure that the solution I found isn't working because of some of the other things I tried but...
First thing I tried was following a tutorial for installing Thin with a Rails app on Centos, (from Slicehost's docs) Slicehost Articles: CentOS - thin web server for Ruby and did a whole bunch of thin configurations. But I don't believe this was necessary because private_pub/faye is supposed to handle this all for you. (from what I understand)
One important thing is that I know you need to use the startup that private_pub describes, even though you can start thin directly.
RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -D -E production
The '-D' makes sure that it runs as a background process.
In my private_pub.yml:
production:
server: "http://myapp.example.com:9292/faye"
secret_token: "{SECRET_TOKEN HERE}"
signature_expiration: 3600 # one hour
I added in the port# here and it all works now.

thin slow in development when not using localhost

I switched to using thin in local development instead of webrick.
When I access localhost:3000 it returns the page almost instantly just like webrick
But when I access myapp.local:3000 the browser spins for 20 seconds or so on each request before rendering the page. I'm not sure what it's doing during that time - the rails log shows the page being generated almost instantly - it almost seems like the browser is doing name resolution during that time or something else.
In my /etc/hosts i have
127.0.0.1 myapp.local
In webrick there was no difference between accessing myapp.local:3000 and localhost:3000.
But in thin there is the large difference mentioned above. Any theories? Much appreciated!
Look for the file /usr/lib/ruby/VERSION_OF_RUBY/webrick/config.rb and edit it.
Replace/insert the following line as a new key of the General hash.
:DoNotReverseLookup => true
Restart webrick.
Otherwise try running sudo service avahi-daemon stop
See Webrick is very slow to respond. How to speed it up? for more details

Using Ubuntu 11.04, I can't shut down rails server using CTRL-C

For some reason, when I type "rails s", sometimes I can't shut the server down using CTRL-C. It's using Web brick, the default.
Sometimes it works for hours. Other times it doesn't work at all and I must constantly kill the process if I want to shut down the server.
Is this a known problem? How can I fix it?
If you need to know more info, please just ask and I'll tell you what I can. Because I don't know what is causing it, I am at a loss as to what info to provide you with.
EDIT: I am adding a git repository:
gem 'rails-dev-boost', :git => 'git://github.com/thedarkone/rails-dev-boost.git', :require => 'rails_development_boost'
But to be fair, I've not had this problem with this line enabled... and I've also had this problem when this gem line didn't exist.
The way I solved this problem was to do the following:
To stop the rails server while it's running, press:
CTRL-C
CTRL-Z
You will get control back to bash. Then type (without the $):
$ fg
And this will go back into the process, and then quit out of Rails s properly.
It's a little annoying, but this sure beats killing the process manually. It's not too bad and it's the best I could figure out.
This is a kernel bug that affects Ubuntu 11.04 (it's fixed in 11.10, fwiw). You can install kernel 2.6.39 to fix it.
I'm using the xorg-edgers PPA which includes 2.6.39, and I don't experience the issue.

Mongrel not detecting changes in Rails classes?

I have a Rails app installed on a Slicehost server running Apache 2 and Ubuntu LTC 10.04. Things have worked beautifully up until now: I edit a file, do a quick mongrel_rails cluster::restart, and the changes are reflected in production. However, suddenly this process has broken down.
For example, I have a class called Master located in /lib/master.rb. I added a new method to this class that simply runs puts "it works!", then restarted the mongrel cluster. Looking at the production logs, the server throws an error and thinks this method doesn't exist. When I go to the console using ruby script/console production, however, I can use this new method perfectly. I even tried deleting the file containing entire Master class. Once again, the production thought it was still there, but the production console correctly recognized it was missing.
Any ideas? How can the production environment detect a class that doesn't even exist anymore?
Funny, I spend 2 hours debugging this, then post to StackOverflow and figure it out in 20 minutes.
The problem is that I needed to also restart my background jobs as well. They were running the old version of the classes stored in /lib. It's interesting that this problem has never snagged me before.

Resources