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

此生再无相见时 提交于 2019-12-10 11:26:05

问题


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 ?


回答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.




回答2:


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.




回答3:


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




回答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 :)




回答5:


start rubyw script/rails server webrick

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



来源:https://stackoverflow.com/questions/4446154/ruby-on-rails-how-to-start-the-webrick-server-automatically-on-windows-in-backg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!