Ruby on Rails: How to start the WEBrick server automatically on Windows in background?

12,571

Solution 1

The simpler way is to create a batch file with the instruction what you give in the command prompt like

d:

cd projects\myapp

ruby script\server

and then drop a copy of the file to Windows Start -> All Programs -> start up folder.

Solution 2

start rubyw script/rails server webrick

start -> start in another console rubyw -> run ruby detached from console

Solution 3

You have few possibilities to do that.

using the registry you can use HKLM\Software\Microsoft\Windows\CurrentVersion\Run or the better approach would be to create a service, you can see this KB with some instruction how to make a service of whatever executable you want.

Solution 4

The best approach is turn your application into a service. There is a solution for Mongrel (a web server similar to webrick) called mongrel_service, but is not compatible with Rails 3 (due several changes of Rails internals)

However, you can repurpose mongrel_service codebase to work with thin, another webserver that works with Rails 3.

Please look here where is the only reference to mongrel_service script. changing it to thin start could work.

Perhaps is not the answer you're looking for (as there is some work to be done) but is something :)

Solution 5

have you thought about , AUTOEXEC.BAT or creating some batch files. you create right cmd commands that are run at start up. http://www.aumha.org/a/batches.php

Share:
12,571
Misha Moroshko
Author by

Misha Moroshko

I build products that make humans happier. Previously Front End engineer at Facebook. Now, reimagining live experiences at https://muso.live

Updated on June 05, 2022

Comments

  • Misha Moroshko
    Misha Moroshko about 2 years

    In order to run the my Rails application on Windows XP I open a command line, cd to application's directory, and then run rails server.

    I would like to automate this, such that every time I turn on my computer, all I'll have to do is to type localhost:3000 in a browser.

    How could I do this ?