Newbie! How to return to the command prompt after launching rails server

Hi

I am following the Ruby on Rails Tutorial: Learn Rails by Example

I am on chapter 2 creating the demo app using scaffolding and have generated the user scaffold, migrated the database using Rake and then run the local webserver using 'rails s'

This has all worked great and I now need to generate the next bit of scaffolding but I don't know how to get back to the command prompt after using 'rails s' . I know I could launch another terminal session but is this the only way? Will I be leaving one terminal open running 'rails s' all the time and another to actually work on?

As anyone can tell I am a total newbie to Ruby on Rails but I am keen to learn and very much appreciate any help with my dumb starter questions!!

Thanks

Matt

rails server -d (or --daemon) will start up the server process in the background and return you to your terminal prompt (at least on Linux or OS/X, I haven’t tried it in Windows). But you do get useful output in the server window in terms of error messages and deprecation warnings, so it’s probably worth letting it keep it’s own terminal.

In fact you’ll probably end up finding it useful to have three or four terminal running at once so as to monitor the rails server, log files, your tests running under autotest plus one to actually do stuff in!

Mark

Hi,

you can stop the server with Ctrl+C. If you want to let you application run all the time in the background just open a new terminal. Another solution would be to start the server as a deamon 'rails s -d'. But i would recommend you to let the server output in its own terminal so you can see if something is going wrong.

Regards, Max.

Hey Matt,

Are you using RoR on Windows platform and MySQL as the db?? Curiously !! I'm using the same and have troubles starting with my first application in RoR..Even I'm a newborn to Ruby on Rails....

Hi Premanshu,

No I am running on a Mac with Snow Leopard but it is using mysql I believe.

Hi,

don't worry, there's no dummy questions, everyone had to start somewhere.

On UNIX based systems (MacOS or Linux) just press CTRL+C, and the server will stop.

Later it can be a good idea to install Thin, because it starts faster, you do not have to wait when you rebooting server. Then just run "ruby script/server -thin" (if I remember well).

Good idea, to run the server in a console, and work in another one, it's just a trick, not essential.

good luck, gezope

Zoltan Gero wrote:

don't worry, there's no dummy questions, everyone had to start somewhere.

On UNIX based systems (MacOS or Linux) just press CTRL+C, and the server will stop.

Later it can be a good idea to install Thin, because it starts faster, you do not have to wait when you rebooting server. Then just run "ruby script/server -thin" (if I remember well).

There's actually a new option, which I think is fantastic:

gem install passenger --pre cd your_rails_project passenger start

This will allow you to run using the server that will most likely power your Rails application in production, but with the same conveniences as rails s. You can stop passenger in the same way with (Ctrl-C). Another nice convenience is that if you need to restart, you can touch tmp/restart.txt just like you would on the deployment server.

As mentioned by others, it is common and very convenient to run the server in a separate terminal. I generally have three terminal tabs open when developing Rails. One for running command line generators and rake, a second for running autotest (w/ autotest-growl), and a third for running passenger and monitoring the development log.

Note: The first time you use passenger start it will install a number of things. Most notably Nginx, which makes developing locally work in a very similar environment to what production will be.

Hey Everyone,

Thanks so much for all the responses, some really helpful stuff!

This is the first time I've posted on here and I'm blown away at how good the support community is!

Zoltan I have copied your note so that I can install passenger when I understand a bit more about what I am doing - Thanks so much for this.

Matt