ruby on rails如何杀死resque worker

时间:2022-05-23 12:00:39

I run the crawler in resque queue.It's a crawler and fetch information into the database... I want to stop it .. then I start the console in the server I use the commands:

我在resque队列中运行爬虫。它是一个爬虫并将信息提取到数据库中......我想停止它..然后我在服务器中启动控制台我使用命令:

irb(main):001:0> Resque.working[0].id
=> "09ec127d-bb90-4629-a6f2-bb2610885ab5:62:*"
irb(main):003:0> Resque.remove_worker("09ec127d-bb90-4629-a6f2-bb2610885ab5:62:*")
=> 0

Although in the /resque page...it shows no worker is running...but I found in the database is increasing....It is still writing data into the database..

虽然在/ resque页面...它显示没有工作正在运行...但我发现在数据库中正在增加....它仍在将数据写入数据库..

1 个解决方案

#1


3  

Here is how I kill my workers :

这是我如何杀死我的工人:

pids = Array.new

puts "Killing resque workers ... "
Resque.workers.each do |worker|
  pids << worker.to_s.split(/:/).second
end

if pids.size > 0
   system("kill -QUIT #{pids.join(' ')}")
end

#1


3  

Here is how I kill my workers :

这是我如何杀死我的工人:

pids = Array.new

puts "Killing resque workers ... "
Resque.workers.each do |worker|
  pids << worker.to_s.split(/:/).second
end

if pids.size > 0
   system("kill -QUIT #{pids.join(' ')}")
end