Adds a method for retrying stuck jobs (#112)
This commit is contained in:
@@ -31,6 +31,7 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
|
||||
"""
|
||||
@impl true
|
||||
def init(state) do
|
||||
reset_executing_jobs()
|
||||
apply_default_settings()
|
||||
ensure_directories_are_writeable()
|
||||
rename_old_job_workers()
|
||||
@@ -38,6 +39,13 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
|
||||
{:ok, state}
|
||||
end
|
||||
|
||||
# If a node cannot gracefully shut down, the currently executing jobs get stuck
|
||||
# in the "executing" state. This is a problem because the job runner will not
|
||||
# pick them up again
|
||||
defp reset_executing_jobs do
|
||||
Repo.update_all(from(j in Oban.Job, where: j.state == "executing"), set: [state: "retryable"])
|
||||
end
|
||||
|
||||
defp apply_default_settings do
|
||||
Settings.fetch!(:onboarding, true)
|
||||
Settings.fetch!(:pro_enabled, false)
|
||||
|
||||
Reference in New Issue
Block a user