好吧,我有這個工作了(從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
而你回家了!