第一页加载后,Ruby on Rails瘦服务器在开发模式下挂起

时间:2014-03-12 06:29:38

标签: ruby-on-rails ruby ruby-on-rails-4 thin

我希望能够开发同时在SSL和非SSL模式下运行的rails应用程序,而无需重新启动服务器以查看对应用程序的修改,也无需在中间需要apache或其他服务器。该应用程序是一个配置和构建Apache的控制面板,因此中间的第三方服务器不是一个选项。

我使用thin(和nodejs)设置rails开发服务器,如果config.cache_classes = false,它会在第一次加载页面后挂起。

起初我通过添加config.threadsafe解决了悬挂问题!到development.rb文件的末尾。当我开始创建应用程序时,服务器没有重新启动就没有应用我的更改。当我在config.threadsafe之后添加config.cache_classes = false时!第一页加载后服务器返回挂起状态。

如何在第一页加载后停止服务器挂起,并且仍然能够看到对应用程序所做的更改而无需重新启动服务器?

Ruby 1.9.3
Rails 4.0.3
Debian 7.4 (Wheezy)

thin.yml

user: appuser 
group: appuser 
pid: tmp/pids/thin.pid
timeout: 30
wait: 30
log: log/thin.log
max_conns: 1024
require: []
environment: development
max_persistent_conns: 512
servers: 1
threaded: true
no-epoll: true
daemonize: true
port: 2082
chdir: /path/to/app
tag: myapp aux

development.rb

DControlPanel::Application.configure do

  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  config.threadsafe!
  config.cache_classes = false

end

/etc/init.d/myapp

#!/bin/bash
### BEGIN INIT INFO
# Provides: myapp
# Required-Start: $local_fs $remote_fs $syslog $named $network $time
# Required-Stop: $local_fs $remote_fs $syslog $named $network
# Default-Start: 3 5
# Default-Stop: 0 1 6
# Short-Description: myapp applications
# Description: myapp applications
### END INIT INFO
# Author: Name <email@domain.tld>
user="appuser"

railsstart() {
load_rvm="source /home/$user/.rvm/scripts/rvm"
thin="bundle exec thin -C config/thin.yml"
thinssl="bundle exec thin --ssl -C config/thin-ssl.yml"

path="/path/to/app"
command=$1
echo "$load_rvm && cd $path && $thin $command && $thinssl $command"

}


# Aktionen
case "$1" in
start)
exec sudo -u $user bash -c "`railsstart start` "
;;
stop)
exec sudo -u $user bash -c "`railsstart stop`"
;;
restart)
exec sudo -u $user bash -c "`railsstart restart`"
;;
esac

exit 0

0 个答案:

没有答案