我在rails应用程序中使用sidekiq.默认情况下,任何人都可以通过在网址后附加"/ sidekiq"来访问Sidekiq.我想密码保护/验证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) 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 ,为什么输出打印.