self-hosted posthog has been down right after I rebooted my vps

Solution 1:

First things first, this is a docker-compose stack, not Kubernetes. If you take a look at the script you execute, you can see that it's downlowading docker compose and then uses it to start up your stack. As such, executing docker-compose stop && docker-compose start after your rebooted should fix this.

The "problem" here is the docker compose yaml that is used for the hobby project, which includes the following:

   caddy:
        image: caddy
        restart: unless-stopped
        ports:
            - '80:80'
            - '443:443'

https://github.com/PostHog/posthog/blob/153b58d9f906fb6f99df942364017738b565d068/docker-compose.hobby.yml#L87

The behavior of the unless-stoppped command is, that a given container is not restarted, if it was stopped.

unless-stopped Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts.

The important part for you is "even after Docker daemon restarts", which is happening as part of your reboot.

Hence, Caddy isn't running, and your service isn't available.