You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in Exq.Api, I couldn't find any api to kill busy job.
there exists remove_job but it can remove a job listed in queue only.
there also exists clear_processes but nothing happens.
If i forced to kill busy job using Process.exit, and restart my app,
then Exq re-enqueues the job i killed.
for the most cases, i think, restoring is very helpful and i love it.
but in my case, i need to kill it without restoring.
is there any way of doing it?
short snippet:
defmodule App.SampleWorker do
def perform() do
IO.puts "SampleWorker start"
:timer.sleep(20_000)
IO.puts "SampleWorker end"
end
end
i don't think this is beautiful but i've finally achieved it by doing flushdb after killing all the busy jobs.
def factory_reset() do
with {:ok, processes} <- Exq.Api.processes(Exq.Api) do
processes
|> Enum.map(&extract_pid/1)
|> Enum.each(&kill_process/1)
end
Exq.Redis.Connection.flushdb!(Exq.Redis.Client)
Application.get_env(:exq, :queues)
|> Enum.each(fn {queue, concurrency} -> Exq.subscribe(Exq, queue, concurrency) end)
end
defp kill_process(pid) do
Process.exit(pid, :kill)
end
defp extract_pid(process) do
process.pid |> String.replace(~r/[<>]/, "") |> IEx.Helpers.pid()
end
in Exq.Api, I couldn't find any api to kill busy job.
there exists
remove_job
but it can remove a job listed in queue only.there also exists
clear_processes
but nothing happens.If i forced to kill busy job using Process.exit, and restart my app,
then Exq re-enqueues the job i killed.
for the most cases, i think, restoring is very helpful and i love it.
but in my case, i need to kill it without restoring.
is there any way of doing it?
short snippet:
iex:
after restart:
thank you.
The text was updated successfully, but these errors were encountered: