SenexCrenshaw / StreamMaster

MIT License
159 stars 20 forks source link

streammaster v0.14.0 PostgreSQL not ready #215

Open Till1012 opened 4 months ago

Till1012 commented 4 months ago

Hello, the new version (v0.14.0) won't launch on a fresh docker-compose install. Previous versions launched just fine. I'm using the docker-compose file from the wiki.

Output of docker-compose:

[+] Running 2/1 ✔ Network streammaster_default Created 0.1s ✔ Container streammaster Created 0.0s Attaching to streammaster streammaster | Allowing use of questionable username. streammaster | Adding user nonRootUser' ... streammaster | Adding new groupnonRootUser' (1000) ... streammaster | Adding new user nonRootUser' (1000) with groupnonRootUser (1000)' ... streammaster | Creating home directory /home/nonRootUser' ... streammaster | Copying files from/etc/skel' ... streammaster | Adding new user nonRootUser' to supplemental / extra groupsusers' ... streammaster | Adding user nonRootUser' to groupusers' ... streammaster | Changing ownership of /app to 1000:1000 streammaster | Changing ownership of /config to 1000:1000 streammaster | Configuration: streammaster | -------------- streammaster | PGADMIN: streammaster | Platform Type: debian streammaster | Setup Email: admin@sm.com streammaster | Setup Password: **** streammaster | POSTGRES: streammaster | User: sm streammaster | Password: **** streammaster | DB Name: StreamMaster streammaster | Data Directory: /config/DB streammaster | Set Perms: 1 streammaster | OS: streammaster | User: postgres Group: postgres streammaster | UID: 100 GID: 102 streammaster | No backup files found in /config/Restore. streammaster | No files ready for restoration. streammaster | The files belonging to this database system will be owned by user "postgres". streammaster | This user must also own the server process. streammaster | streammaster | The database cluster will be initialized with locale "C". streammaster | The default database encoding has accordingly been set to "SQL_ASCII". streammaster | The default text search configuration will be set to "english". streammaster | streammaster | Data page checksums are disabled. streammaster | streammaster | initdb: error: directory "/config/DB" exists but is not empty streammaster | initdb: hint: If you want to create a new database system, either remove or empty the directory "/config/DB" or run initdb with an argument other than "/config/DB". streammaster | Attempt 1: PostgreSQL is not yet ready on 127.0.0.1:5432. Retrying in 5 seconds... streammaster | Attempt 2: PostgreSQL is not yet ready on 127.0.0.1:5432. Retrying in 5 seconds... streammaster | Attempt 3: PostgreSQL is not yet ready on 127.0.0.1:5432. Retrying in 5 seconds... streammaster | Attempt 4: PostgreSQL is not yet ready on 127.0.0.1:5432. Retrying in 5 seconds... streammaster | Attempt 5: PostgreSQL is not yet ready on 127.0.0.1:5432. Retrying in 5 seconds... streammaster | Attempt 6: PostgreSQL is not yet ready on 127.0.0.1:5432. Retrying in 5 seconds... streammaster | Attempt 7: PostgreSQL is not yet ready on 127.0.0.1:5432. Retrying in 5 seconds... streammaster | Attempt 8: PostgreSQL is not yet ready on 127.0.0.1:5432. Retrying in 5 seconds

brunomgalmeida commented 4 months ago

Its because of the directory Backup inside. Why not use the postgres docker image instead, and remove all the manual db configuration? And/or support sqlite?

infosecmatters2021 commented 3 months ago

It looks to me that the PUID (1000) and PGID (1000) aren't respected. Postgres is the owner of the database and must also own the server process. Postgres is PUID=100 and PGID=102.

Not necessarily the best answer (but works) - update the PUID and PGID to match postgres. The streammaster directory (volume) also requires the same ownership/group.

Log excerpt: streammaster | Changing ownership of /app to 1000:1000 streammaster | Changing ownership of /config to 1000:1000 ... streammaster | User: postgres Group: postgres streammaster | UID: 100 GID: 102 … streammaster | The files belonging to this database system will be owned by user "postgres". streammaster | This user must also own the server process.

Changes: environment:

volumes:

~/.streammaster needs its permissions set to 100 (chown) and 102 (chgrp).

infosecmatters2021 commented 3 months ago

Pulled the latest code that includes the update to this issue. Set PUID and PGID in Docker compose. Set directory permissions (streammaster and all sub-folders) to same user/group. Started streammaster. It appears to be the same issue. (Once launched, the DB directory permissions are set to 100/102.)

Changing ownership of /app to 1026:100 Changing ownership of /config to 1026:100 ... OS: User: 1026 Group: 100 User: postgres Group: postgres UID: 100 GID: 102 No backup files found in /config/Restore. No files ready for restoration. Attempt 1: PostgreSQL is not yet ready on 127.0.0.1:5432. Retrying in 5 seconds... mkdir: cannot create directory '/config': Permission denied

macinsight commented 3 months ago

Yup, experiencing the same on 0.14.4, this is a fatal bug on systems where you're unable to get UID 100 (e.g. shared seedboxes where you don't have root) and causes SM to be stuck in "Attempt 2: PostgreSQL is not yet ready on 127.0.0.1:5432. Retrying in 5 seconds..." which repeats ad infinitum

capps1994 commented 2 months ago

if this had a separate postgres container, you could also so the depends_on attribute meaning that the streammaster container will not start until postgres is up

w-marco commented 2 months ago

With 0.14.5 (which is available on Dockerhub), you can use external PSQLs:

https://github.com/SenexCrenshaw/StreamMaster/issues/217#issuecomment-2080621813