小编use*_*078的帖子

Ruby模块中的常量范围

我在mixin模块中有一个恒定范围的问题.假设我有类似的东西

module Auth

  USER_KEY = "user" unless defined? USER_KEY

  def authorize
    user_id = session[USER_KEY]
  def

end
Run Code Online (Sandbox Code Playgroud)

除非已经定义,否则USER_KEY常量应默认为"user".现在我可以将它混合到几个地方,但在其中一个地方USER_KEY需要不同,所以我们可能会有这样的东西

class ApplicationController < ActionController::Base

  USER_KEY = "my_user"

  include Auth

  def test_auth
    authorize
  end

end
Run Code Online (Sandbox Code Playgroud)

我希望USER_KEY在授权中使用时会是"my_user",因为它已经定义了,但它仍然是"user",取自USER_KEY的模块定义.任何人都知道如何授权使用USER_KEY的类版本?

ruby module ruby-on-rails constants

54
推荐指数
3
解决办法
5万
查看次数

使用bluepill监视bundle exec unicorn_rails

由于unicorn_rails抱怨不同的gem版本,我们在bluepill文件中移动了bundle exec unicorn_rails ... 这个变化解决了特定问题和事情的开始和停止,但是当我们尝试sudo bluepill状态时,我们现在得到了

独角兽(pix:XXXXXX):不受监控

看起来像bluepill现在没有监控独角兽进程.如果我停止子进程,它将重新启动子进程,但不会重新启动父进程.

我已经四处寻找,但对这个问题找不到多少,并希望有人可以对此有所了解.bluepill配置文件是

app_dir = "/opt/local/share/httpd/apps/xyz"
Bluepill.application('xyz', :log_file => "#{app_dir}/current/log/bluepill.log") do |app|
  app.process('unicorn') do |process|
    process.pid_file    = "#{app_dir}/shared/pids/unicorn.pid"
    process.working_dir = "#{app_dir}/current"

    process.stdout = process.stderr = "#{app_dir}/shared/log/unicorn.err.log"
    process.start_command = "bundle exec unicorn_rails -D -c #{app_dir}/current/config/environments/production/unicorn.rb -E production"
    process.stop_command = "kill -QUIT {{PID}}"
    process.restart_command = "kill -USR2 {{PID}}"

    process.start_grace_time = 8.seconds
    process.stop_grace_time = 5.seconds
    process.restart_grace_time = 13.seconds

    process.monitor_children do |child_process|
      child_process.stop_command = "kill -QUIT {{PID}}"

      child_process.checks :mem_usage, :every => 10.seconds, :below => 200.megabytes, :times => [3,5] …
Run Code Online (Sandbox Code Playgroud)

unicorn bundler bluepill

5
推荐指数
1
解决办法
2373
查看次数

标签 统计

bluepill ×1

bundler ×1

constants ×1

module ×1

ruby ×1

ruby-on-rails ×1

unicorn ×1