【问题标题】:RoR in Windows not working for pre-existing app built with RoR in linuxWindows 中的 RoR 不适用于在 linux 中使用 RoR 构建的预先存在的应用程序
【发布时间】:2016-07-27 00:27:03
【问题描述】:

我已经在 Windows 8 中使用 RailsInstaller 和 postgresql 安装了 Ruby on Rails。我正在尝试使用现有应用程序的文件运行 rails server,但我收到错误消息“JRuby 不支持工作模式或视窗'。

在我的 config/puma.rb 文件中,我将工作人员设置为 0,然后收到有关 Windows 不支持守护程序模式的错误。基本上每次我改变一些东西我都会得到更多的错误。

我已经修复了环境变量、gem 等(就像在其他帖子中一样),例如 Cannot install Puma gem on Ruby on Rails.,有没有希望在 Windows 机器上运行预先存在的内置于 linux 的 RoR 应用程序?

当我为 RoR“博客”示例运行 rails server 时,它运行良好,所以我知道 RoR 肯定可以在 Windows 中运行!

这是我的 -'de-identified' config/puma.rb 文件。是因为在 Windows 中我没有 /var/app 文件夹吗?我玩过目录等无济于事。

`
#!/usr/bin/env puma

# start puma with:
# RAILS_ENV=production bundle exec puma -C ./config/puma.rb

workers 0
theident = 'nameofthing'
application_path =  '/var/app/'+ theident + '.address.com.au/current'
railsenv = 'production'
directory application_path
environment railsenv
daemonize false
pidfile "#{application_path}/tmp/pids/puma-#{railsenv}.pid"
state_path "#{application_path}/tmp/pids/puma-#{railsenv}.state"
stdout_redirect"#{application_path}/log/puma-#{theident}.log"
threads 0, 16
bind "unix:///var/run/puma/" + theident + "_app.sock" `

我已将这些目录更改为当前路径,现在正在运行的“rails server”开始运行,但 localhost:3000 是一个无法正常工作的页面。我在 SIGUSR1 不工作、SIGUSR2 不工作等方面遇到错误

【问题讨论】:

    标签: ruby-on-rails linux postgresql ruby-on-rails-3 windows-8


    【解决方案1】:

    JRuby 和 Windows 都不支持“workers”方法,因此最好的解决方案是从 puma.rb 中删除导致错误的行。就我而言,我删除了;

    workers Integer(ENV['WEB_CONCURRENCY'] || 2)
    

    所以我还有;

    threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
    threads threads_count, threads_count
    
    preload_app!
    
    rackup      DefaultRackup
    port        ENV['PORT']     || 3000
    environment ENV['RACK_ENV'] || 'development'
    
    on_worker_boot do
      # Worker specific setup for Rails 4.1+
      # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
      ActiveRecord::Base.establish_connection
    end
    

    对你来说可能会有所不同,但具体的行将以“workers”开头

    【讨论】:

    • 感谢您的建议 - 最后我不得不从我的 gemfile 中删除 puma gem 并安装 node js 才能让它工作!
    猜你喜欢
    • 2011-07-07
    • 1970-01-01
    • 2015-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多