小编sag*_*kar的帖子

如何密码保护我的/ sidekiq路由(即需要对Sidekiq :: Web工具进行身份验证)?

我在rails应用程序中使用sidekiq.默认情况下,任何人都可以通过在网址后附加"/ sidekiq"来访问Sidekiq.我想密码保护/验证sidekiq部分.我怎样才能做到这一点?

ruby rescue redis ruby-on-rails-3 sidekiq

53
推荐指数
6
解决办法
2万
查看次数

用capistrano开始sidekiq

我想用capistrano开始sidekiq.下面是代码

namespace :sidekiq do
  task :start do
    run "cd #{current_path} && bundle exec sidekiq -c 10 -e production -L log/sidekiq.log &"
    p capture("ps aux | grep sidekiq | awk '{print $2}' | sed -n 1p").strip!    
  end
end
Run Code Online (Sandbox Code Playgroud)

它成功执行但仍未在服务器上启动sidekiq.

输出:

$ cap sidekiq:start
    triggering load callbacks
  * 2014-06-03 15:03:01 executing `sidekiq:start'
  * executing "cd /home/project/current && bundle exec sidekiq -c 10 -e production -L log/sidekiq.log &"
    servers: ["x.x.x.x"]
    [x.x.x.x] executing command
    command finished in 1229ms
  * executing "ps aux | grep …
Run Code Online (Sandbox Code Playgroud)

ruby capistrano ruby-on-rails-3 sidekiq

5
推荐指数
2
解决办法
7566
查看次数

Ruby在创建对象时自动调用to_s方法

class A
  def initialize(string, number)
    @string = string
    @number = number
  end

  def to_s
    "In to_s:\n   #{@string}, #{@number}\n"
  end
  def to_a
    "In to_a:\n   #{@string}, #{@number}\n"
  end
end
puts a = A.new("hello world", 5)
Run Code Online (Sandbox Code Playgroud)

输出是

 In to_s:
   hello world, 5
Run Code Online (Sandbox Code Playgroud)

to_s方法如何自动调用?

为什么不自动调用另一种方法如to_a

由于我没有在to_s方法中写入put ,为什么输出打印.

ruby ruby-1.9.3

2
推荐指数
1
解决办法
2827
查看次数

标签 统计

ruby ×3

ruby-on-rails-3 ×2

sidekiq ×2

capistrano ×1

redis ×1

rescue ×1

ruby-1.9.3 ×1