【问题标题】:run rails in background process -windows在后台进程中运行 rails -windows
【发布时间】:2013-02-07 08:43:47
【问题描述】:

我在 windows pc 上的 rails 安装程序上创建了一个桌面浏览器应用程序。现在我正在尝试运行rails s -p3001 -e production -d。它不在电脑上运行。

如何分离windows pc上的应用服务器进程?

这是错误

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

【问题讨论】:

  • -d选项用于让服务器在后台运行;所以你做对了。运行命令时会收到什么(错误)消息?
  • 嗨@PrakashMurthy。我刚刚更新了我的问题请检查日志.. 这是在 windows pc 上

标签: ruby-on-rails windows ruby-on-rails-3.2 detach


【解决方案1】:

错误信息说得很清楚:fork() function is unimp lemented on this machine (NotImplementedError)

rails 服务器被守护的方式是调用机器上的fork system call。以下是 rails repo 中的相关代码:exit if fork

它在 windows pc 上失败,因为 Windows Operating System 没有实现 fork 系统调用。

一种选择可能是按照this answer to What is the closest thing windows has to fork()? 中的建议在 Windows 电脑上安装 Cygwin

【讨论】:

  • 这是一个很好的答案但是我无法在 Windows 上创建后台进程。我已经在 Windows 上自行创建了服务。但是谢谢@Prakash
【解决方案2】:

我已经参考链接解决了这个问题 :: run rails in background process -windows

感谢穆尔蒂的回答

【讨论】:

  • 我已经创建了服务文件,在文件夹中添加了 exe 文件和 conf 文件。现在我的应用正在使用自动服务。
猜你喜欢
  • 1970-01-01
  • 2013-02-04
  • 1970-01-01
  • 2023-03-10
  • 2021-04-06
  • 2012-10-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多