Ruby on Rails: How to start the WEBrick server automatically on Windows in background?
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, a开发者_StackOverflowll I'll have to do is to type localhost:3000
in a browser.
How could I do this ?
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.
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.
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
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 :)
start rubyw script/rails server webrick
start -> start in another console rubyw -> run ruby detached from console
精彩评论