Adds a method for retrying stuck jobs (#112)

This commit is contained in:
Kieran 2024-03-24 09:21:01 -07:00 committed by GitHub
parent ecc73d25a5
commit d0f7338f42
2 changed files with 8 additions and 28 deletions

View file

@ -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)