mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 10:16:07 +02:00
In shell mode, only do database setup once (#1686)
We were initializing ofy and JPA every time the command was run, causing shell commands to break after 64 transactions.
This commit is contained in:
parent
63e4f4f10a
commit
eb1b283ba3
1 changed files with 17 additions and 13 deletions
|
@ -256,20 +256,24 @@ final class RegistryCli implements AutoCloseable, CommandRunner {
|
|||
options, new ByteArrayInputStream(component.googleCredentialJson().getBytes(UTF_8)));
|
||||
}
|
||||
installer.install(options);
|
||||
|
||||
// Database setup -- we also only ever do this if "installer" is null, just so that it's
|
||||
// only done once.
|
||||
|
||||
// Ensure that all entity classes are loaded before command code runs.
|
||||
ObjectifyService.initOfy();
|
||||
// Make sure we start the command with a clean cache, so that any previous command won't
|
||||
// interfere with this one.
|
||||
ofyTm().clearSessionCache();
|
||||
|
||||
// Enable Cloud SQL for command that needs remote API as they will very likely use
|
||||
// Cloud SQL after the database migration. Note that the DB password is stored in Datastore
|
||||
// and it is already initialized above.
|
||||
TransactionManagerFactory.setJpaTm(
|
||||
() -> component.nomulusToolJpaTransactionManager().get());
|
||||
TransactionManagerFactory.setReplicaJpaTm(
|
||||
() -> component.nomulusToolReplicaJpaTransactionManager().get());
|
||||
}
|
||||
|
||||
// Ensure that all entity classes are loaded before command code runs.
|
||||
ObjectifyService.initOfy();
|
||||
// Make sure we start the command with a clean cache, so that any previous command won't
|
||||
// interfere with this one.
|
||||
ofyTm().clearSessionCache();
|
||||
|
||||
// Enable Cloud SQL for command that needs remote API as they will very likely use
|
||||
// Cloud SQL after the database migration. Note that the DB password is stored in Datastore
|
||||
// and it is already initialized above.
|
||||
TransactionManagerFactory.setJpaTm(() -> component.nomulusToolJpaTransactionManager().get());
|
||||
TransactionManagerFactory.setReplicaJpaTm(
|
||||
() -> component.nomulusToolReplicaJpaTransactionManager().get());
|
||||
}
|
||||
|
||||
command.run();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue