繁体   English   中英

在Windows的后台运行webrick服务器

[英]Running webrick server in background for Windows

我想在Windows的后台运行Webrick服务器,尝试跟着没有运气:

>rails s -d
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.0.4/lib/active_support/values/time_zone.rb:283: warning: circular argument reference - now
=> Booting WEBrick
=> Rails 4.0.4 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-1.5.5/lib/rack/server.rb:327:in `daemon': daemon() function is unimplemented on this machine (NotImplementedError)
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-1.5.5/lib/rack/server.rb:327:in `daemonize_app'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-1.5.5/lib/rack/server.rb:252:in `start'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.0.4/lib/rails/commands/server.rb:84:in `start'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.0.4/lib/rails/commands.rb:76:in `block in <top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.0.4/lib/rails/commands.rb:71:in `tap'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.0.4/lib/rails/commands.rb:71:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

我该如何解决这个问题?

来自Ali MasudianPour和brad的解决方案:

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=start=之后的空格。没有它们就无法工作)

然后开始吧

net start railsapp

你回家了!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM