Open Martinsos opened 1 year ago
This is related to #730 since they will in big part probably use the same mechanisms.
@sodic suggested quick soluiton to just use another port than 5432 so to avoid clash with postgres process users might already have running on their machine.
What we want
Right now, when Wasp runs a managed dev db (e.g. via
wasp start db
), it will run it on port 5432. If that port is already occupied by some other process, or by another Wasp app, starting the db will fail.Potential solutions
To solve this, we can do one of two (or both) things:
Solution implementation details
There are two parts of Wasp that need to know the port: the part where db is started, and later when Wasp project is generated. The only way to transfer that knowledge is to write it down to disk somehow, temporarily. So when managed dev db starts, Wasp should write down the port that it used to start it, to some local, hidden, non-versioned file, that then other wasp processes (for example if you run
wasp start
orwasp db migrate-dev
) can read and obtain info about the port from it.So far this was not needed because port was hardcoded to 5432, but for this change we will need this sharing of knowledge.
One thing to keep an eye on is that while we can write that file with info about port once that mangaed dev db stars running, we can't guarantee it will get deleted once managed dev db stops running, so we shouldn't even try to delete it we can just give up on that. That means that when we do read that file, we should not assume that means that managed dev db is running -> it just means that if it is running, it is running with this port. But ok, that makes sense!
As for which file could that be, the one into which we write port into -> hm, not sure, we don't have that kind of file yet actually, it would probably have to be a new file. We could store it into .wasp/ dir.