如何在我的Windows服务器上为mongrel/rails安装此service_wrapper?

bra*_*rad 3 windows-services mongrel windows-server-2008 ruby-on-rails-3

我已经得到了安装我在Windows Server 2008上编写的Rails 3应用程序的不愉快的任务(绝对不是我的选择 - 承诺了一个Linux服务器但是IT在最后一分钟拉出了地毯所以请不要建议改变环境作为解决方案).

我按照这篇博客文章中的说明进行了一些小修改,现在实际上让我的应用程序在Windows/IIS(代理mongrel)下运行并经受了很大的挫折.唯一剩下的就是让mongrel作为服务运行.

不幸的是,mongrel gem并没有保持Rails 3的最新状态,虽然我可以在命令行下使用mongrel运行应用程序但是我无法使用mongrel_service来使应用程序作为服务运行.

对此的解决方案似乎是在github上使用service_wrapper项目,该项目已在前一个问题中提到.该项目尚未完成,但显然功能齐全,但没有文档/二进制文件.我查看了源代码,并没有真正理解它是什么/它是如何工作的,所以想知道是否有人可以指出我正确的方向(或者,更好的,请指导我如何)来安装它.

如此接近,但仍然如此......

bra*_*rad 8

好吧,我已经解决了这个问题(在luislavena亲自帮助下 - 谢谢).

https://github.com/luislavena/service_wrapper/downloads下载service_wrapper-0.1.0-win32.zip 并从bin /中解压缩service_wrapper.exe.我将它解压缩到C:\ service_wrapper.

接下来设置配置文件.我使用了hello示例并将其修改为我的应用程序,然后将其放在C:\ service_wrapper目录中.

; Service section, it will be the only section read by service_wrapper
[service]

; Provide full path to executable to avoid issues when executable path was not
; added to system PATH.
executable = C:\Ruby192\bin\ruby.exe

; Provide there the arguments you will pass to executable from the command line
arguments = C:\railsapp\script\rails s -e production

; Which directory will be used when invoking executable.
; Provide a full path to the directory (not to a file)
directory = C:\railsapp

; Optionally specify a logfile where both STDOUT and STDERR of executable will
; be redirected.
; Please note that full path is also required.
logfile = C:\railsapp\log\service_wrapper.log
Run Code Online (Sandbox Code Playgroud)

现在只需创建服务即可

sc create railsapp binPath= "C:\service_wrapper\service_wrapper.exe C:\service_wrapper\service_wrapper.conf" start= auto
Run Code Online (Sandbox Code Playgroud)

(注意binPath =和start =之后的空格.没有它们就无法工作)

然后开始吧

net start railsapp
Run Code Online (Sandbox Code Playgroud)

你回家了!