midarrlabs / midarr-server

🔥Midarr, the minimal lightweight media server.
MIT License
1.24k stars 39 forks source link

[BUG]: Unable to start in podman #396

Closed gab9281 closed 1 year ago

gab9281 commented 1 year ago

Describe the bug Midarr doesn't start due to missing socket under podman

To Reproduce Steps to reproduce the behavior:

Expected behavior The app should be starting

Additional context

Investigation : After some investigation of the entry-local.sh file I was able to validate the connexion of the database with the pg_isready -q -h $DB_HOSTNAME -U $DB_USERNAME

The issue seem to stem from the fact that podman-compose does not share correctly the socket and crashed when using the psql -Atqc "\\list $DB_DATABASE" command.

Crash log :

podman start -a midarr_postgresql
[midarr_postgresql] | The files belonging to this database system will be owned by user "postgres".
[midarr_postgresql] | This user must also own the server process.
[midarr_postgresql] | 
[midarr_postgresql] | The database cluster will be initialized with locale "en_US.utf8".
[midarr_postgresql] | The default database encoding has accordingly been set to "UTF8".
[midarr_postgresql] | The default text search configuration will be set to "english".
[midarr_postgresql] | 
[midarr_postgresql] | Data page checksums are disabled.
[midarr_postgresql] | 
[midarr_postgresql] | fixing permissions on existing directory /var/lib/postgresql/data ... ok
[midarr_postgresql] | creating subdirectories ... ok
[midarr_postgresql] | selecting dynamic shared memory implementation ... posix
[midarr_postgresql] | selecting default max_connections ... 100
[midarr_postgresql] | selecting default shared_buffers ... 128MB
[midarr_postgresql] | selecting default time zone ... Etc/UTC
[midarr_postgresql] | creating configuration files ... ok
[midarr_postgresql] | running bootstrap script ... ok
podman start -a midarr
[midarr_postgresql] | performing post-bootstrap initialization ... ok
[midarr]            | Resolving Hex dependencies...
[midarr]            | Resolution completed in 0.324s
[midarr]            | Unchanged:
[midarr]            |   bcrypt_elixir 3.0.1
[midarr]            |   castore 1.0.3
[midarr]            |   certifi 2.9.0
[midarr]            |   comeonin 5.3.3
[midarr]            |   cors_plug 3.0.3
[midarr]            |   cowboy 2.10.0
[midarr]            |   cowboy_telemetry 0.4.0
[midarr]            |   cowlib 2.12.1
[midarr]            |   db_connection 2.5.0
[midarr]            |   decimal 2.1.1
[midarr]            |   ecto 3.10.1
[midarr]            |   ecto_sql 3.10.1
[midarr]            |   elixir_make 0.7.6
[midarr]            |   esbuild 0.7.1
[midarr]            |   excoveralls 0.17.0
[midarr]            |   exile 0.1.0
[midarr]            |   expo 0.4.1
[midarr]            |   exstream 0.20.0
[midarr]            |   extaima 0.3.0
[midarr]            |   extitles 0.1.0
[midarr]            |   file_system 0.2.10
[midarr]            |   floki 0.34.3
[midarr]            |   gettext 0.23.0
[midarr]            |   hackney 1.18.1
[midarr]            |   httpoison 2.1.0
[midarr]            |   idna 6.1.1
[midarr]            |   jason 1.4.1
[midarr]            |   metrics 1.0.1
[midarr]            |   mime 2.0.5
[midarr]            |   mimerl 1.2.0
[midarr]            |   oauth2 2.1.0
[midarr]            |   parse_trans 3.3.1
[midarr]            |   phoenix 1.7.7
[midarr]            |   phoenix_ecto 4.4.2
[midarr]            |   phoenix_html 3.3.2
[midarr]            |   phoenix_live_dashboard 0.7.2
[midarr]            |   phoenix_live_reload 1.4.1
[midarr]            |   phoenix_live_view 0.18.18
[midarr]            |   phoenix_pubsub 2.1.3
[midarr]            |   phoenix_template 1.0.2
[midarr]            |   phoenix_view 2.0.2
[midarr]            |   plug 1.14.2
[midarr]            |   plug_cowboy 2.6.1
[midarr]            |   plug_crypto 1.2.5
[midarr]            |   postgrex 0.17.2
[midarr]            |   ranch 1.8.0
[midarr]            |   scrivener 2.7.2
[midarr]            |   ssl_verify_fun 1.1.7
[midarr]            |   swoosh 1.11.5
[midarr]            |   tailwind 0.2.1
[midarr]            |   telemetry 1.2.1
[midarr]            |   telemetry_metrics 0.6.1
[midarr]            |   telemetry_poller 1.0.0
[midarr]            |   tesla 1.7.0
[midarr]            |   unicode_util_compat 0.7.0
[midarr]            |   websock 0.5.2
[midarr]            |   websock_adapter 0.5.3
[midarr]            | All dependencies are up to date
[midarr]            | Mon Aug 21 05:06:39 UTC 2023 - waiting for database to start
[midarr]            | Mon Aug 21 05:06:41 UTC 2023 - waiting for database to start
[midarr]            | Mon Aug 21 05:06:43 UTC 2023 - waiting for database to start
[midarr]            | Mon Aug 21 05:06:45 UTC 2023 - waiting for database to start
initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
[midarr_postgresql] | syncing data to disk ... ok
[midarr_postgresql] | 
[midarr_postgresql] | 
[midarr_postgresql] | Success. You can now start the database server using:
[midarr_postgresql] | 
[midarr_postgresql] |     pg_ctl -D /var/lib/postgresql/data -l logfile start
[midarr_postgresql] | 
[midarr_postgresql] | waiting for server to start....2023-08-21 05:06:47.805 UTC [46] LOG:  starting PostgreSQL 15.4 (Debian 15.4-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
[midarr_postgresql] | 2023-08-21 05:06:47.817 UTC [46] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
[midarr_postgresql] | 2023-08-21 05:06:47.841 UTC [49] LOG:  database system was shut down at 2023-08-21 05:06:38 UTC
[midarr_postgresql] | 2023-08-21 05:06:47.848 UTC [46] LOG:  database system is ready to accept connections
[midarr_postgresql] |  done
[midarr_postgresql] | server started
[midarr]            | Mon Aug 21 05:06:47 UTC 2023 - waiting for database to start
[midarr_postgresql] | CREATE DATABASE
[midarr_postgresql] | 
[midarr_postgresql] | 
[midarr_postgresql] | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
[midarr_postgresql] | 
[midarr_postgresql] | 2023-08-21 05:06:48.017 UTC [46] LOG:  received fast shutdown request
[midarr_postgresql] | waiting for server to shut down....2023-08-21 05:06:48.019 UTC [46] LOG:  aborting any active transactions
[midarr_postgresql] | 2023-08-21 05:06:48.021 UTC [46] LOG:  background worker "logical replication launcher" (PID 52) exited with exit code 1
[midarr_postgresql] | 2023-08-21 05:06:48.021 UTC [47] LOG:  shutting down
[midarr_postgresql] | 2023-08-21 05:06:48.025 UTC [47] LOG:  checkpoint starting: shutdown immediate
[midarr]            | Mon Aug 21 05:06:49 UTC 2023 - waiting for database to start
[midarr_postgresql] | ..2023-08-21 05:06:50.424 UTC [47] LOG:  checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.051 s, sync=2.279 s, total=2.403 s; sync files=301, longest=0.050 s, average=0.008 s; distance=4223 kB, estimate=4223 kB
[midarr_postgresql] | 2023-08-21 05:06:50.429 UTC [46] LOG:  database system is shut down
[midarr_postgresql] |  done
[midarr_postgresql] | server stopped
[midarr_postgresql] | 
[midarr_postgresql] | PostgreSQL init process complete; ready for start up.
[midarr_postgresql] | 
2023-08-21 05:06:50.590 UTC [1] LOG:  starting PostgreSQL 15.4 (Debian 15.4-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2023-08-21 05:06:50.603 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-08-21 05:06:50.603 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-08-21 05:06:50.644 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-08-21 05:06:50.705 UTC [62] LOG:  database system was shut down at 2023-08-21 05:06:50 UTC
2023-08-21 05:06:50.727 UTC [1] LOG:  database system is ready to accept connections
psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?
[midarr]            | 
[midarr]            | 05:06:53.113 [info] == Running 20211216025410 MediaServer.Repo.Migrations.CreateUsersAuthTables.change/0 forward
[midarr]            | 
[midarr]            | 05:06:53.125 [info] execute "CREATE EXTENSION IF NOT EXISTS citext"
[midarr]            | 
[midarr]            | 05:06:53.185 [info] create table users
[midarr]            | 
[midarr]            | 05:06:53.226 [info] create index users_email_index
[midarr]            | 
[midarr]            | 05:06:53.246 [info] create table users_tokens
[midarr]            | 
[midarr]            | 05:06:53.260 [info] create index users_tokens_user_id_index
[midarr]            | 
[midarr]            | 05:06:53.265 [info] create index users_tokens_context_token_index
[midarr]            | 
[midarr]            | 05:06:53.283 [info] == Migrated 20211216025410 in 0.1s
[midarr]            | 
[midarr]            | 05:06:53.355 [info] == Running 20221027035542 MediaServer.Repo.Migrations.CreateMediaTypes.change/0 forward
[midarr]            | 
[midarr]            | 05:06:53.356 [info] create table media_types
[midarr]            | 
[midarr]            | 05:06:53.375 [info] create index media_types_type_index
[midarr]            | 
[midarr]            | 05:06:53.386 [info] == Migrated 20221027035542 in 0.0s
[midarr]            | 
[midarr]            | 05:06:53.409 [info] == Running 20221027035545 MediaServer.Repo.Migrations.Actions.change/0 forward
[midarr]            | 
[midarr]            | 05:06:53.410 [info] create table actions
[midarr]            | 
[midarr]            | 05:06:53.424 [info] create index actions_action_index
[midarr]            | 
[midarr]            | 05:06:53.429 [info] == Migrated 20221027035545 in 0.0s
[midarr]            | 
[midarr]            | 05:06:53.438 [info] == Running 20221027035546 MediaServer.Repo.Migrations.CreateContinues.change/0 forward
[midarr]            | 
[midarr]            | 05:06:53.438 [info] create table continues
[midarr]            | 
[midarr]            | 05:06:53.448 [info] == Migrated 20221027035546 in 0.0s
[midarr]            | 
[midarr]            | 05:06:53.465 [info] == Running 20221027035547 MediaServer.Repo.Migrations.CreateMediaActions.change/0 forward
[midarr]            | 
[midarr]            | 05:06:53.466 [info] create table media_actions
[midarr]            | 
[midarr]            | 05:06:53.472 [info] == Migrated 20221027035547 in 0.0s
[midarr]            | 05:06:54.607 [notice] Application media_server exited: MediaServer.Application.start(:normal, []) returned an error: shutdown: failed to start child: MediaServer.SeriesIndex
[midarr]            |     ** (EXIT) an exception was raised:
[midarr]            |         ** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): DBConnection.PrepareStream, DBConnection.Stream, Date.Range, Ecto.Adapters.SQL.Stream, Exile.Stream, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Jason.OrderedObject, List, Map, MapSet, Phoenix.LiveView.LiveStream, Postgrex.Stream, Range, Scrivener.Page, Stream
[midarr]            |             (elixir 1.14.3) lib/enum.ex:1: Enumerable.impl_for!/1
[midarr]            |             (elixir 1.14.3) lib/enum.ex:166: Enumerable.reduce/3
[midarr]            |             (elixir 1.14.3) lib/enum.ex:4307: Enum.filter/2
[midarr]            |             (media_server 4.0.0) lib/media_server_web/repositories/series.ex:17: MediaServerWeb.Repositories.Series.get_all/0
[midarr]            |             (elixir 1.14.3) lib/agent/server.ex:8: Agent.Server.init/1
[midarr]            |             (stdlib 3.17.2.2) gen_server.erl:423: :gen_server.init_it/2
[midarr]            |             (stdlib 3.17.2.2) gen_server.erl:390: :gen_server.init_it/6
[midarr]            |             (stdlib 3.17.2.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
[midarr]            | {"Kernel pid terminated",application_controller,"{application_start_failure,media_server,{{shutdown,{failed_to_start_child,'Elixir.MediaServer.SeriesIndex',{#{'__exception__' => true,'__struct__' => 'Elixir.Protocol.UndefinedError',description => <<>>,protocol => 'Elixir.Enumerable',value => nil},[{'Elixir.Enumerable','impl_for!',1,[{file,\"lib/enum.ex\"},{line,1}]},{'Elixir.Enumerable',reduce,3,[{file,\"lib/enum.ex\"},{line,166}]},{'Elixir.Enum',filter,2,[{file,\"lib/enum.ex\"},{line,4307}]},{'Elixir.MediaServerWeb.Repositories.Series',get_all,0,[{file,\"lib/media_server_web/repositories/series.ex\"},{line,17}]},{'Elixir.Agent.Server',init,1,[{file,\"lib/agent/server.ex\"},{line,8}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,423}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}}},{'Elixir.MediaServer.Application',start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,media_server,{{shutdown,{failed_to_start_child,'Elixir.MediaServer.SeriesIndex',{#{'__exception__' => true,'__struct__' => 'Elixir.Protocol.UndefinedError',description => <<>>,protocol => 'Elixir.Enumerable',value => nil},[{'Elixir.Enumerable','impl_for!',1,[{file,"lib/enum.ex"},{line,1}]},{'Elixir.Enumerable',reduce,3,[{file,"lib/enum.ex"},{line,166}]},{'Elixir.Enum',filter,2,[{file,"lib/enum.ex"},{line,4307}]},{'Elixir.MediaServerWeb.Repositories.Series',get_all,0,[{file,"lib/media_server_web/repositories/series.ex"},{line,17}]},{'Elixir.Agent.Server',init,1,[{file,"lib/agent/server.ex"},{line,8}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,423}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}}},{'Elixir.MediaServer.Application',start,[normal,[]]}}})

Crash dump is being written to: erl_crash.dump...done
[midarr]            | Database my_database ready
[midarr]            | 05:06:57.418 [info] Running MediaServerWeb.Endpoint with cowboy 2.10.0 at :::4000 (http)
[midarr]            | 05:06:57.428 [info] Access MediaServerWeb.Endpoint at http://localhost:4000
[midarr]            | 05:06:57.470 [notice] Application media_server exited: MediaServer.Application.start(:normal, []) returned an error: shutdown: failed to start child: MediaServer.SeriesIndex
[midarr]            |     ** (EXIT) an exception was raised:
[midarr]            |         ** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): DBConnection.PrepareStream, DBConnection.Stream, Date.Range, Ecto.Adapters.SQL.Stream, Exile.Stream, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Jason.OrderedObject, List, Map, MapSet, Phoenix.LiveView.LiveStream, Postgrex.Stream, Range, Scrivener.Page, Stream
[midarr]            |             (elixir 1.14.3) lib/enum.ex:1: Enumerable.impl_for!/1
[midarr]            |             (elixir 1.14.3) lib/enum.ex:166: Enumerable.reduce/3
[midarr]            |             (elixir 1.14.3) lib/enum.ex:4307: Enum.filter/2
[midarr]            |             (media_server 4.0.0) lib/media_server_web/repositories/series.ex:17: MediaServerWeb.Repositories.Series.get_all/0
[midarr]            |             (elixir 1.14.3) lib/agent/server.ex:8: Agent.Server.init/1
[midarr]            |             (stdlib 3.17.2.2) gen_server.erl:423: :gen_server.init_it/2
[midarr]            |             (stdlib 3.17.2.2) gen_server.erl:390: :gen_server.init_it/6
[midarr]            |             (stdlib 3.17.2.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
[midarr]            | {"Kernel pid terminated",application_controller,"{application_start_failure,media_server,{{shutdown,{failed_to_start_child,'Elixir.MediaServer.SeriesIndex',{#{'__exception__' => true,'__struct__' => 'Elixir.Protocol.UndefinedError',description => <<>>,protocol => 'Elixir.Enumerable',value => nil},[{'Elixir.Enumerable','impl_for!',1,[{file,\"lib/enum.ex\"},{line,1}]},{'Elixir.Enumerable',reduce,3,[{file,\"lib/enum.ex\"},{line,166}]},{'Elixir.Enum',filter,2,[{file,\"lib/enum.ex\"},{line,4307}]},{'Elixir.MediaServerWeb.Repositories.Series',get_all,0,[{file,\"lib/media_server_web/repositories/series.ex\"},{line,17}]},{'Elixir.Agent.Server',init,1,[{file,\"lib/agent/server.ex\"},{line,8}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,423}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}}},{'Elixir.MediaServer.Application',start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,media_server,{{shutdown,{failed_to_start_child,'Elixir.MediaServer.SeriesIndex',{#{'__exception__' => true,'__struct__' => 'Elixir.Protocol.UndefinedError',description => <<>>,protocol => 'Elixir.Enumerable',value => nil},[{'Elixir.Enumerable','impl_for!',1,[{file,"lib/enum.ex"},{line,1}]},{'Elixir.Enumerable',reduce,3,[{file,"lib/enum.ex"},{line,166}]},{'Elixir.Enum',filter,2,[{file,"lib/enum.ex"},{line,4307}]},{'Elixir.MediaServerWeb.Repositories.Series',get_all,0,[{file,"lib/media_server_web/repositories/series.ex"},{line,17}]},{'Elixir.Agent.Server',init,1,[{file,"lib/agent/server.ex"},{line,8}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,423}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}}},{'Elixir.MediaServer.Application',start,[normal,[]]}}})

Crash dump is being written to: erl_crash.dump...done
exit code: 1
trueChazza commented 1 year ago

Hi thank you for opening the issue.

Based on your logs please check your Sonarr environment variables are correct. Also, if there are no series to show from Sonarr it will crash like this too. Are you running Sonarr v3?

gab9281 commented 1 year ago

I am using sonarr development branch sadly. With what I see , It doesn't even connect to the database ( tried using -it )

trueChazza commented 1 year ago

It’s does connect to the database, your migrations / db setup was completed.

It’s crashing on Sonarr unfortunately.

gab9281 commented 1 year ago

Oh okay , well ... I'll wait for support then . Thanks

kjkent commented 1 year ago

As an aside, I'm glad this issue exists as I couldn't figure why Midarr was crashing like this for me; I don't use Sonarr and was hoping to use Midarr to serve files I manually placed in the media folder. Is this possible at all?

trueChazza commented 1 year ago

As an aside, I'm glad this issue exists as I couldn't figure why Midarr was crashing like this for me; I don't use Sonarr and was hoping to use Midarr to serve files I manually placed in the media folder. Is this possible at all?

Hi, unfortunately no this is not possible. Midarr relies on both Radarr and Sonarr for an index to your media.

kjkent commented 1 year ago

@trueChazza I appreciate the reply, though -- thanks for clarifying!

runaroundhome commented 1 year ago

I was getting the same errors, then I realised I too was running on sonarr develop (and radarr nightly).

I see you're add more details to the error logs https://github.com/midarrlabs/midarr-server/issues/403#issuecomment-1703632855, big thumbs up. May I suggest mentioning in the logs to check what brand/version of sonarr / radarr they're running too, if it's failing. As it looks like at least develop isn't supported yet. (and I don't blame you, just my feedback)

PS, loving the project, and can't wait to give it a try.

trueChazza commented 1 year ago

May I suggest mentioning in the logs to check what brand/version of sonarr / radarr they're running too, if it's failing.

Great idea thank you! I've added these to the Radarr and Sonarr issues.