Ruby on Rails:如何在 Windows 上后台自动启动 WEBrick 服务器?
为了在 Windows XP 上运行我的 Rails 应用程序,我打开命令行,cd 到应用程序的目录,然后运行 rails server
。
我想自动执行此操作,这样每次打开计算机时,我所要做的就是在浏览器中输入 localhost:3000
。
我怎么能这样做呢?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
更简单的方法是使用您在命令提示符中给出的指令创建一个批处理文件,例如
然后将该文件的副本拖放到 Windows 开始 ->所有程序 ->启动文件夹。
The simpler way is to create a batch file with the instruction what you give in the command prompt like
and then drop a copy of the file to Windows Start -> All Programs -> start up folder.
你这样做的可能性很小。
使用注册表,您可以使用
HKLM\Software\Microsoft\Windows\CurrentVersion\Run
< /a> 或者更好的方法是创建一个服务,您可以查看此知识库,其中包含一些内容说明如何为您想要的任何可执行文件提供服务。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.您是否考虑过 AUTOEXEC.BAT 或创建一些批处理文件。您创建在启动时运行的正确 cmd 命令。 http://www.aumha.org/a/batches.php
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
最好的方法是将您的应用程序转变为服务。 Mongrel(类似于 webrick 的 Web 服务器)有一个名为 mongrel_service 的解决方案,但与 Rails 不兼容3(由于 Rails 内部发生了一些变化)
但是,您可以重新调整 mongrel_service 代码库的用途,以与瘦,另一个与 Rails 3 一起使用的网络服务器一起使用。
请查看 这里是对 mongrel_service 脚本的唯一引用。将其更改为
thin start
可能会起作用。也许不是您正在寻找的答案(因为还有一些工作要做),但确实是这样:)
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 :)
启动 rubyw 脚本/rails 服务器 webrick
start ->在另一个控制台中启动
红宝石->脱离控制台运行 ruby
start rubyw script/rails server webrick
start -> start in another console
rubyw -> run ruby detached from console