mirror of
https://github.com/kieraneglin/pinchflat.git
synced 2026-01-23 10:26:07 +00:00
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.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
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue