matheusgomes28 / urchin

Headless CMS written in Golang
MIT License
60 stars 19 forks source link

Database connection checks at startup #51

Closed matheusgomes28 closed 5 months ago

matheusgomes28 commented 5 months ago

It seems like the App starts up even when the database connection isn't right.

The following line does not return an error when the connection isn't valid in cmd/urchin/main.go:

db_connection, err := database.MakeSqlConnection(
  app_settings.DatabaseUser,
  app_settings.DatabasePassword,
  app_settings.DatabaseAddress,
  app_settings.DatabasePort,
  app_settings.DatabaseName,
)

Make it so we check the connection and fail fast if the DB connection is invalid!

Milad75Rasouli commented 5 months ago

Hi, I do "ping" the database after establishing the connection. it's more likely to handle the issue. I'll fix it today after work, if you don't mind?

Milad75Rasouli commented 5 months ago

it's my idea to fix the issue:

    err = db.Ping()
    if err != nil {
        return nil, err
    }

what do you say?

matheusgomes28 commented 5 months ago

Hey @Milad75Rasouli , the plan sounds good!

If you push the fix, I can review it after work. Please don't forget to run the project and make sure it still works as intended 😄

Milad75Rasouli commented 5 months ago

@matheusgomes28 TBH, you've made the running project flow a bit difficult. either your scripts for running the project or the Dockerfile and docker-compose files need to be improved. IMO, there are a lot of thing to do with them, however I'll do my change and run the project for sure. A solid document to explain new contributors how to run the project is required.

matheusgomes28 commented 5 months ago

@Milad75Rasouli I agree, I'm gathering some feedback to figure out how to make the flow easier.

I definitely need more instructions on the README.md for sure, for starters. Feel free to raise any issues with potential feedback on improving the workflow too, in case you have suggestions.

AlDu2407 commented 5 months ago

@matheusgomes28 TBH, you've made the running project flow a bit difficult. either your scripts for running the project or the Dockerfile and docker-compose files need to be improved. IMO, there are a lot of thing to do with them, however I'll do my change and run the project for sure. A solid document to explain new contributors how to run the project is required.

I'm preparing a PR with additional documentation and an easier setup for starting the development process. Will create it by the next weekend and it should make the onboarding process easier. You'll have to wait for it until next weekend though. :)

matheusgomes28 commented 5 months ago

closed with #53