3

我得到了安裝一個Rails 3應用程序的不愉快任務,我在Windows Server 2008上編寫了這個應用程序(絕對不是我的選擇 - 曾承諾過一個Linux服務器,但IT在最後一分鐘將地毯拉出來,所以請不要建議作爲解決方案改變環境)。如何在我的Windows服務器上安裝mongrel/rails的service_wrapper?

我按照this blog post(有一些小的修改)的說明,現在實際上讓我的應用程序在Windows/IIS(proxying mongrel)下運行並經受了很多挫折。剩下的唯一東西就是讓雜種作爲服務運行。

不幸的是,雜種寶石並沒有保持最新的Rails 3,雖然我可以讓應用程序在命令行下運行,但我無法使用mongrel_service來讓應用程序作爲服務運行。

解決方案似乎是使用this previous question中提到的github上的service_wrapper項目。該項目尚未完成,但顯然功能,但沒有文件/二進制文件。我已經瀏覽了源代碼,並且不知道它是什麼/它是如何工作的,所以想知道是否有人能夠指引我朝着正確的方向(或者,甚至更好地指導我如何)來安裝它。

如此接近,但仍到目前爲止.....

回答

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 

現在只需創建

sc create railsapp binPath= "C:\service_wrapper\service_wrapper.exe C:\service_wrapper\service_wrapper.conf" start= auto 

(觀看binPath後空間=開始=,不會沒有他們的工作)

然後用

啓動它的服務
net start railsapp 

而你回家了!

1

我應該爲這篇文章做出貢獻。對於使用bundle exec的配置,請使用以下命令: 請注意,我正在設置rubyCAS!這是一個很棒的OpenCAS認證機制!

; 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:\Ruby\bin\ruby.exe 

; Provide there the arguments you will pass to executable from the command line 
arguments = D:\rubycas-server bundle exec rackup -s mongrel -p 11011 

; Which directory will be used when invoking executable. 
; Provide a full path to the directory (not to a file) 
directory = D:\rubycas-server 

; Optionally specify a logfile where both STDOUT and STDERR of executable will 
; be redirected. 
; Please note that full path is also required. 
logfile = D:\rubycas-server\log\service_wrapper.log 
相關問題