wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.
https://wasp-lang.dev
MIT License
13.63k stars 1.18k forks source link

Have `wasp start db` produce nice warning message if docker daemon is not running #1135

Open Martinsos opened 1 year ago

Martinsos commented 1 year ago

This is what it currently looks like:

✨ Starting a PostgreSQL dev database (based on your Wasp config) ✨

Additional info:
 ℹ Connection URL, in case you might want to connect with external tools:
     postgresql://postgresWaspDevUser:postgresWaspDevPass@localhost:5432/SaaSTemplate-f587f704d3
 ℹ Database data is persisted in a docker volume with the following name (useful to know if you will want to delete it at some point):
     wasp-dev-db-SaaSTemplate-f587f704d3

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
wasp-bin: callCommand: docker run --name wasp-dev-db-SaaSTemplate-f587f704d3 --rm --publish 5432:5432 -v wasp-dev-db-SaaSTemplate-f587f704d3:/var/lib/postgresql/data --env POSTGRES_PASSWORD=postgresWaspDevPass --env POSTGRES_USER=postgresWaspDevUser --env POSTGRES_DB=SaaSTemplate-f587f704d3 postgres (exit 125): failed

While I thought message here is clear ("Is the docker daemon running") it turns out, based on feedback, that it is easy to miss. So it would be much better if we detected this explicitly with Wasp and provided a nice, explicit error message about it + some instructions on how to go about it.

We will probably want to run docker info and parse its output to determine if docker daemon is running or not.

Martinsos commented 1 year ago

We decided to close this one for now, as it is not so simple for us to correctly detect if docker deamon is not running, and result will be us investing work into at the end mostly forwarding docker errors while they are already being forwarded. We can reopen if the need is great and then consider the solution again, but at this moment I think it is not worth the effort.

infomiho commented 1 year ago

I would maybe consider doing the most basic check possible (without parsing the error that Docker produces and doing some smart error reporting). Just some simple output modification if docker info errors.

What we have now

Screenshot 2023-06-02 at 16 29 35
  1. We say "The db is starting"
  2. We say "Here's the connection string"
  3. But then a Docker error shows up

What I propose

If we detect an exit code 1 from docker info or similar we alter the output to be:

  1. Hey something is wrong with Docker, run docker info to see (or we just show the output)

and that's it.

I feel it improves the experience for our users since Wasp exits earlier and doesn't give mixed signals (here's the connection string but also an error).

Custom error message gives the opportunity to educate our users as well:

Martinsos commented 1 year ago

Ok so the main purpose of this is to run it first, so they see that first, and don't have a feeling that db started already. Ok makes sense!

I am voting for forwarding the error output to them, but also telling them to investigate on their own.

We could possibly even go a step further then and try to figure out if error was caused by the fact that docker daemon is not running, and if so, let them know that explicitly. But we can also skip that.

Btw I just quickly tested if docker info actually does return error when docker deamon is not running, and ok yeah, it seems it does -> I had to stop both docker.service and docker.socket though, stopping just docker.service wasn't enough, but I guess that makes sense? I don't know enough which does what, would have to investigate.

Martinsos commented 1 year ago

@modotte @infomiho gave some fresh ideas here on how to approach this simply, so if you are still interested, it might be worth trying out this new direction. If you are occupied with other stuff don't worry, no expectations here, just wanted to keep you in the loop :).

Martinsos commented 7 months ago

User on Discord found docker missing to be a bit complicated to figure out: https://discord.com/channels/686873244791210014/1216028386829537362/1216028386829537362 .