Restarted existing blog with latest docker images and now haven wont come up.
Pulled latest as of today for the haven docker images and then restarted only to find the first time, the blog came up with no customisations and no images... but blog posts.
Restarting it a second time leads to a indefinite loop on restarting haven-1 pod.
Any help greatly appreciated... blog is unusable currently. :/
Example start loop...
✔ Container haven-postgresql-haven-1 Created 0.0s
✔ Container haven-haven-1 Created 0.0s
Attaching to haven-1, postgresql-haven-1
postgresql-haven-1 |
postgresql-haven-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgresql-haven-1 |
postgresql-haven-1 | 2025-06-23 00:38:51.123 UTC [1] LOG: starting PostgreSQL 16.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014, 64-bit
postgresql-haven-1 | 2025-06-23 00:38:51.123 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgresql-haven-1 | 2025-06-23 00:38:51.123 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgresql-haven-1 | 2025-06-23 00:38:51.124 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgresql-haven-1 | 2025-06-23 00:38:51.125 UTC [24] LOG: database system was shut down at 2025-06-23 00:37:01 UTC
postgresql-haven-1 | 2025-06-23 00:38:51.129 UTC [1] LOG: database system is ready to accept connections
postgresql-haven-1 | 2025-06-23 00:38:52.408 UTC [28] ERROR: database "haven" already exists
postgresql-haven-1 | 2025-06-23 00:38:52.408 UTC [28] STATEMENT: CREATE DATABASE "haven" ENCODING = 'unicode'
haven-1 | Database 'haven' already exists
haven-1 | User with email [email protected] already exists, skipping user creation
haven-1 | => Booting Puma
haven-1 | => Rails 7.0.8.7 application starting in production
haven-1 | => Run `bin/rails server --help` for more startup options
haven-1 | Exiting
haven-1 | A server is already running. Check /app/tmp/pids/server.pid.
haven-1 exited with code 0
postgresql-haven-1 | 2025-06-23 00:38:58.708 UTC [32] ERROR: database "haven" already exists
postgresql-haven-1 | 2025-06-23 00:38:58.708 UTC [32] STATEMENT: CREATE DATABASE "haven" ENCODING = 'unicode'
haven-1 | Database 'haven' already exists
haven-1 | User with email [email protected] already exists, skipping user creation
haven-1 | => Booting Puma
haven-1 | => Rails 7.0.8.7 application starting in production
haven-1 | => Run `bin/rails server --help` for more startup options
haven-1 | A server is already running. Check /app/tmp/pids/server.pid.
haven-1 | Exiting
haven-1 exited with code 0
postgresql-haven-1 | 2025-06-23 00:39:05.064 UTC [36] ERROR: database "haven" already exists
postgresql-haven-1 | 2025-06-23 00:39:05.064 UTC [36] STATEMENT: CREATE DATABASE "haven" ENCODING = 'unicode'
haven-1 | Database 'haven' already exists
haven-1 | User with email [email protected] already exists, skipping user creation
haven-1 | => Booting Puma
haven-1 | => Rails 7.0.8.7 application starting in production
haven-1 | => Run `bin/rails server --help` for more startup options
haven-1 | A server is already running. Check /app/tmp/pids/server.pid.
haven-1 | Exiting
haven-1 exited with code 1
postgresql-haven-1 | 2025-06-23 00:39:11.507 UTC [41] ERROR: database "haven" already exists
postgresql-haven-1 | 2025-06-23 00:39:11.507 UTC [41] STATEMENT: CREATE DATABASE "haven" ENCODING = 'unicode'
haven-1 | Database 'haven' already exists
Gracefully stopping... (press Ctrl+C again to force)
I've reverted back to https://github.com/havenweb/haven/pkgs/container/haven/370239358?tag=e18a854 which is approximately the last time I believe I pulled a new latest. This is working for me.
Apologies, there was a recent change to the docker base image that forced me to move image storage to a different directory. Instead of mounting to /storage, it now needs to mount to /app/storage. See docker-compose here: https://github.com/havenweb/haven/blob/master/docker-compose.yml
I suspect this is the breaking change, it came up elsewhere. Remounting that volume to /app/storage resolved the issue in that case.
Thanks for the info... I will look at updating this mount point.
Hey @elapse2039 did this resolve your issue?
Hey! I've encountered the same issue recently when running the docker-compose stack. exactly the logs
haven-1 | A server is already running. Check /app/tmp/pids/server.pid.
haven-1 | Exiting
What happens there?
the server.pid is what Puma and Ruby use for legacy PID tracking of the server successfully started. It makes unnecessary starts useless.
Thing is when you stop the docker-compose stack it does NOT stop Puma, or at least do not do a cleanup of /tmp/pids/server.pid because of the compose being 'smart' and reuse existing volumes.
There are plenty of hacks in Dockerfile that suggest running rm -f the server.pid file from the container as a pre-start cleanup. but this effectively stops us from using the Puma's features of tracking if app started at all.
A good solution was found by Ilija Eftimov in this good article is usage of tmpfs in docker compose ymls.
So I've created a PR for docker-compose.yml to fix this. Fix essentially leverages the tmpfs feature of docker-compose to create ephemeral tmp volume and store the pid file there, so it gets removed as soon as container is down.