ruby-on-rails-4 - 在 Windows 后台运行 webrick 服务器

标签 ruby-on-rails-4 background windows-7 webrick

我想在 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>'

我该如何解决这个问题?

最佳答案

Solution from Ali MasudianPour and 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

你已经回到家并被冲洗了!

关于ruby-on-rails-4 - 在 Windows 后台运行 webrick 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39588519/

相关文章:

android - 如何在 Open GL ES Android 上设置背景颜色

ruby - 使用适当的参数转义从 ruby​​ 在后台执行 shell 命令

css - Chrome 中 @font-face 的可怕渲染

Python selenium lib 未在 Windows 上安装

ruby-on-rails - Sidekiq:NoMethodError:未定义的方法 `perform'

ruby-on-rails - 如何在Rails 4.0中填充activerecord时加载动画?

mysql - 如何在rails中输入一个更大的整数值(超过10位)

后台的 Android 异步任务进度

opengl - Windows 中的 MIDI 嗅探 + OpenGL

ruby-on-rails-4 - 在 Rails 中清理用户输入的最佳方法