oj-lab / oj-lab-platform

Aims to build high-performance & easy-peasy online-judge system
Mozilla Public License 2.0
9 stars 5 forks source link

Check database setup instead of sleep for 10s #84

Closed akamya997 closed 1 month ago

akamya997 commented 2 months ago

When setting up dependencies, in the current Makefile, it simply sleeps for 10s, which may lead to certain problems.

@echo "Wait 10 seconds for db setup"
sleep 10s

For example, if one has set up a postgres server locally using the same password and username, he will fail to use the db oj_lab and spend his day locating the problem.

To solve this, we should check whether the database oj_lab is well set in this step.

Zztrans commented 1 month ago
.PHONY: setup-dependencies
setup-dependencies: unset-dependencies build get-front get-problem-packages
    docker compose up -d postgres redis minio clickhouse
    @echo "Wait 10 seconds for db setup"    
    sleep 10s
    ./bin/init

We can do like this in a shell script while poll:

docker exec oj-lab-platform-postgres-1 psql -U postgres oj_lab

But other service like redis minio, should we also do like this?

It is not so efficient maybe.

slhmy commented 1 month ago

It will be better if we provide cleaning method instead of restarting all the dependencies in docker compose. You can't avoid the startup time too much if we continue to do in the previous way

slhmy commented 1 month ago

Closing this issue and we follow the progress in #97