Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run rails in background process -windows

I have created one desktop browser application on the rails installer on windows pc. Now I am trying to run rails s -p3001 -e production -d. It does not run on the pc.

How to detach the application server process on the windows pc?

Here is the error

=> Booting Thin
 > Rails 3.2.7 application starting in production on http://0.0.0.0:3000
C:/ibt/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib
/active_support/core_ext/process/daemon.rb:3:in `fork': fork() function is unimp
lemented on this machine (NotImplementedError)
    from C:/ibt/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupp
 ort-3.2.7/lib/active_support/core_ext/process/daemon.rb:3:in `daemon'
    from C:/ibt/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.1
/lib/rack/server.rb:314:in `daemonize_app'
    from C:/ibt/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.1
 /lib/rack/server.rb:254:in `start'
    from C:/ibt/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3
.2.7/lib/rails/commands/server.rb:70:in `start'
from C:/ibt/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3
2.7/lib/rails/commands.rb:55:in `block in <top (required)>'
    from C:/ibt/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3
2.7/lib/rails/commands.rb:50:in `tap'
    from C:/ibt/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3
.2.7/lib/rails/commands.rb:50:in `<top (required)>'
     from script/rails:6:in `require'
     from script/rails:6:in `<main>'
like image 391
Arpit Vaishnav Avatar asked May 21 '26 19:05

Arpit Vaishnav


1 Answers

The error message makes it very clear: fork() function is unimp lemented on this machine (NotImplementedError).

The way rails server is daemonized is by calling the fork system call on the machine. Here is the relevant code from the rails repo: exit if fork

It is failing on the windows pc because Windows Operating System doesn't implement a fork system call.

One option might be to install Cygwin on the windows pc as suggested in this answer to What is the closest thing windows has to fork()?

like image 185
Prakash Murthy Avatar answered May 23 '26 10:05

Prakash Murthy