我接到了一项令人不快的任务,要安装我在 Windows Server 2008 上编写的 Rails 3 应用程序(这绝对不是我的选择 - 承诺提供 Linux 服务器,但 I.T. 在最后一刻撤回了,所以请不要建议进行更改)环境作为解决方案)。
我按照以下说明进行操作这篇博文(进行了一些小的修改),在经历了很多挫折之后,现在我的应用程序实际上已经在 Windows/IIS(代理杂种)下启动并运行了。剩下的唯一事情就是让 mongrel 作为服务运行。
不幸的是,Rails 3 的 mongrel gem 尚未保持最新状态,虽然我可以在命令行下让应用程序在 mongrel 下运行,但我无法使用 mongrel_service 让应用程序作为服务运行。
解决这个问题的方法似乎是使用服务包装器github上的项目已经在上一个问题。该项目尚未完成,但显然可以正常运行,但没有文档/二进制文件。我查看了源代码,但并不真正理解它是什么/它是如何工作的,所以想知道是否有人可以给我指出正确的方向(或者更好的是,引导我完成如何安装)来安装它。
如此接近,却又如此遥远......
好吧,我已经解决了(在路易斯拉维纳本人的帮助下 - 谢谢)。
下载 service_wrapper-0.1.0-win32.zip 从https://github.com/luislavena/service_wrapper/downloads并从 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
现在只需创建服务
sc create railsapp binPath= "C:\service_wrapper\service_wrapper.exe C:\service_wrapper\service_wrapper.conf" start= auto
(注意 binPath= 和 start= 之后的空格。没有它们,它将无法工作)
然后开始
net start railsapp
你回到家了!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)