Adds a method for retrying stuck jobs (#112)
This commit is contained in:
parent
ecc73d25a5
commit
d0f7338f42
2 changed files with 8 additions and 28 deletions
28
.iex.exs
28
.iex.exs
|
|
@ -21,31 +21,3 @@ alias Pinchflat.FastIndexing.YoutubeRss
|
||||||
alias Pinchflat.Metadata.MetadataFileHelpers
|
alias Pinchflat.Metadata.MetadataFileHelpers
|
||||||
|
|
||||||
alias Pinchflat.SlowIndexing.FileFollowerServer
|
alias Pinchflat.SlowIndexing.FileFollowerServer
|
||||||
|
|
||||||
defmodule IexHelpers do
|
|
||||||
def last_media_item do
|
|
||||||
Repo.one(from m in MediaItem, limit: 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
def details(type) do
|
|
||||||
source =
|
|
||||||
case type do
|
|
||||||
:playlist -> playlist_url()
|
|
||||||
:channel -> channel_url()
|
|
||||||
end
|
|
||||||
|
|
||||||
YtDlpCollection.get_source_details(source)
|
|
||||||
end
|
|
||||||
|
|
||||||
def ids(type) do
|
|
||||||
source =
|
|
||||||
case type do
|
|
||||||
:playlist -> playlist_url()
|
|
||||||
:channel -> channel_url()
|
|
||||||
end
|
|
||||||
|
|
||||||
YtDlpCollection.get_media_attributes_for_collection(source)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
import IexHelpers
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
|
||||||
"""
|
"""
|
||||||
@impl true
|
@impl true
|
||||||
def init(state) do
|
def init(state) do
|
||||||
|
reset_executing_jobs()
|
||||||
apply_default_settings()
|
apply_default_settings()
|
||||||
ensure_directories_are_writeable()
|
ensure_directories_are_writeable()
|
||||||
rename_old_job_workers()
|
rename_old_job_workers()
|
||||||
|
|
@ -38,6 +39,13 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
|
||||||
{:ok, state}
|
{:ok, state}
|
||||||
end
|
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
|
defp apply_default_settings do
|
||||||
Settings.fetch!(:onboarding, true)
|
Settings.fetch!(:onboarding, true)
|
||||||
Settings.fetch!(:pro_enabled, false)
|
Settings.fetch!(:pro_enabled, false)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue