-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow running cli commands without db connection #235
Comments
This can also impact commands implemented by services, eg, the openapi command. It would be good if the openapi command could be run without needing to start the db |
I don't think this is currently possible with seaorm, but I think it is with sqlx, so we may be able to submit a PR to seaorm to enable this behavior. |
Opened a PR on SEA ORM: SeaQL/sea-orm#2268 |
For redis/sidekiq, we need to move the "stale cleanup" behavior out of the "build" method so it runs after the service is built and after the "handle cli" method is run against the services. |
This should be a quick fix once SeaQL/sea-orm#2268 is merged. |
The seaorm team is taking a while to look at the proposed pr above. An alternative could be to use a OnceLock to lazy init the db connection? |
Hmm, the problem with OnceLock is the db connection creation can return an error, so we would need to add a layer of checks everywhere the db connection is requested. |
Sea-orm added support for lazy database connections. We provide a config field to allow toggling lazy database connections on or off. If lazy connections are enabled, the default `run` method will allow running CLI commands without requiring the the DB connection to be available (unless the CLI command itself attempts to execute a DB query). Closes #235
Creating the app context requires connecting to the db (if a db feature is enabled). If no db is running, the cli will not run. We have a couple options:
RunCommand
trait that runs right after the app config is parsed (and tracing is initialized) and before the app context is created.The text was updated successfully, but these errors were encountered: