0

我已经成功安装了mongrel、mongrel_service、win-32 服务 ,并且在我的电脑上也成功安装了该服务并且正在成功启动。

现在遇到的主要问题是,我的应用程序使用了一组 gem,所以在正常情况下mongrel_rails start将以 bundle exec开头。即使服务启动,杂种也不会启动,因为它必须以bundle exec启动。

我的问题是,如何在创建 Windows 服务的命令中包含 bundle exec 以便它将使用 bundle 启动 mongrels?

还有其他方法吗,可能包括 boot.rb 或 preinitializer.rb 中的 bundle exec 以便它自动加载?我正在使用rails 2.3。

杂种日志如下

** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with production environment...
c:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:31:in
`setup': You have already activated mongrel 1.2.0.pre2, but your Gemfile
requires mongrel 1.2.0.pre2. Using bundle exec may solve this.
(Gem::LoadError)
  from
c:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:17:in
`setup'
  from**strong text**
c:/Ruby/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler.rb:110:in
`setup'
  from c:/xxxxx/xxxxxx/config/../config/preinitializer.rb:17
  from c:/xxxxx/xxxxx/config/boot.rb:26:in `load'
  from c:/xxxxx/xxxxx/config/boot.rb:26:in `preinitialize'
  from c:/xxxxx/xxxxx/config/boot.rb:8:in `boot!'
  from c:/xxxxx/xxxxx/config/boot.rb:120
  from c:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
  from c:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
  from c:/xxxxx/xxxxx/config/environment.rb:5
  from c:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
  from c:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/../lib/mongrel/rails.rb:147:in
`rails'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:116:in
`cloaker_'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/../lib/mongrel/configurator.rb:149:in
`call'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/../lib/mongrel/configurator.rb:149:in
`listener'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:102:in
`cloaker_'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/../lib/mongrel/configurator.rb:50:in
`call'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/../lib/mongrel/configurator.rb:50:in
`initialize'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in
`new'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in
`run'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/../lib/mongrel/command.rb:210:in
`run'
  from
c:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:282
  from c:/Ruby/bin/mongrel_rails:19:in `load'
  from c:/Ruby/bin/mongrel_rails:19
4

1 回答 1

0

我找到了解决这个问题的方法。根据 Luis Lavana 的说法,mongrel_service 已经死了,现在是一个新产品 service_wrapper,它可以轻松地将各种人员作为服务安装。遵循以下流程

  1. https://github.com/luislavena/service_wrapper/downloads下载service_wrapper
  2. service_wrapper.exe从下载的服务包装器的 bin 文件夹中复制到C:\service_wrapper目录中。
  3. 通过打开任何文本编辑器并输入以下内容,为 service_wrapper 创建一个配置文件

; 服务部分,它将是 service_wrapper 读取的唯一部分

[服务]

; ruby​​ 可执行文件的路径

可执行文件 = C:\Ruby\bin\ruby.exe

; ruby​​ 可执行文件的参数

参数 = C:\Ruby\bin\bundle exec mongrel_rails start -p 3000 -e development

;路径你的应用程序目录

目录 = C:\myapp

; 可选地指定一个日志文件,其中 STDOUT 和 STDERR 的可执行文件将 ;被重定向。 ; 请注意,完整路径也是必需的。

日志文件 = C:\service_wrapper\service_wraper_log.log

  1. 将扩展名为“.conf”的文本文件(例如“my_config.conf”)保存到目录中,例如 c:\service_wrapper

  2. 打开命令提示符并键入以下命令以创建 Windows 服务:

sc 创建服务名称 binPath= "c:\service_wrapper\service_wrapper.exe c:\service_wrapper\my_config.conf" start= auto

(注意binPath=start=后面的空格)

  1. 键入net start servicename以启动服务

  2. 等待一段时间,大约 30 秒让 mongrel 启动,您可以在 localhost:3000 打开您的应用程序。

希望它可以帮助某人。

于 2012-09-06T13:27:41.947 回答