Closed leventov closed 4 years ago
I’ve made significant changes to bootstrapping in a beta release of v4. Would you be willing to give this version a try in your environment? It was created for a similar use case in docker we were running into in aws.
I use v4 beta now. Is this the case in the new version that connect()
creates all the necessary tables if they don't exist yet as well as start()
?
The behavior of connect() hasn’t changed, but you should use start() instead, as it will block with a promise how you’re needing.
I think the issue was that if start()
is called from both actors out of necessity (because calling connect()
from either one may result in "tables for pg-boss don't exist..." error), we needlessly do monitoring/archiving from both actors.
Only one instance using start() will issue maintenance commands, so this is fine. I've documented how this works in the changelog
Currently,
start()
is responsible for both creation of pg-boss's tables in the database, and monitoring/archiving jobs. When starting multiple actors using docker-compose (alongside a database), we cannot be sure which actor will hit the database first. So, I think it makes sense to makeconnect()
to also create the tables if they are absent yet. Perhaps, via opt-in boolean parameterconnect(createTables)
.