Running webrick server in the background for Windows

I want to run the Webrick server in the background on Windows, tried to follow with no luck:

>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>'

How can i solve this?

+4
source share
1 answer

Solution from Ali MasoudianPour and brad :

Download service_wrapper-0.1.0-win32.zipfrom https://github.com/luislavena/service_wrapper/downloads and extract service_wrapper.exefrom bin/. I pulled it in C:\service_wrapper.

Then configure the configuration file. I used the welcome example and modified it for my application, and then put it in a directory 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

Now just create a service with

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

( binPath= start=. )

net start railsapp

!

0

Source: https://habr.com/ru/post/1655158/


All Articles