main
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
This commit is contained in:
parent
7d0079c563
commit
d9f23d9e2d
1 changed files with 34 additions and 8 deletions
|
|
@ -26,6 +26,30 @@ late Isar isar;
|
||||||
|
|
||||||
late final String WORK_DIR;
|
late final String WORK_DIR;
|
||||||
|
|
||||||
|
|
||||||
|
Future<Isar> _initIsar(
|
||||||
|
String dir,
|
||||||
|
bool debugMode,
|
||||||
|
) async {
|
||||||
|
var attempt = 0;
|
||||||
|
while (attempt < 5) {
|
||||||
|
print('Attempt $attempt to initialize Isar');
|
||||||
|
try {
|
||||||
|
return isar = await IsarConnector().connect(
|
||||||
|
dir: dir,
|
||||||
|
name: 'db',
|
||||||
|
inspector: debugMode,
|
||||||
|
);
|
||||||
|
} catch (e, s) {
|
||||||
|
print('Error initializing Isar: $e');
|
||||||
|
log('Error initializing Isar: $e', error: e, stackTrace: s);
|
||||||
|
}
|
||||||
|
await Future.delayed(Duration(seconds: attempt * 10));
|
||||||
|
attempt++;
|
||||||
|
}
|
||||||
|
throw Exception('Failed to initialize Isar');
|
||||||
|
}
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
// WidgetsFlutterBinding.ensureInitialized();
|
// WidgetsFlutterBinding.ensureInitialized();
|
||||||
// final dir = (await getApplicationDocumentsDirectory()).path;
|
// final dir = (await getApplicationDocumentsDirectory()).path;
|
||||||
|
|
@ -61,13 +85,9 @@ void main() async {
|
||||||
// await Isar.initializeIsarCore(download: true);
|
// await Isar.initializeIsarCore(download: true);
|
||||||
final debugMode = Platform.environment['DEBUG'] == 'true' ||
|
final debugMode = Platform.environment['DEBUG'] == 'true' ||
|
||||||
Platform.environment['DEBUG'] == '1';
|
Platform.environment['DEBUG'] == '1';
|
||||||
|
|
||||||
isar = await IsarConnector().connect(
|
_initIsar(dir, debugMode).then((isar) async {
|
||||||
dir: dir,
|
getIt.registerSingleton<Isar>(isar);
|
||||||
name: 'db',
|
|
||||||
inspector: debugMode,
|
|
||||||
);
|
|
||||||
getIt.registerSingleton<Isar>(isar);
|
|
||||||
configureDependencies();
|
configureDependencies();
|
||||||
await getIt<MnemoShelf>().initV2();
|
await getIt<MnemoShelf>().initV2();
|
||||||
|
|
||||||
|
|
@ -85,9 +105,15 @@ void main() async {
|
||||||
TasksSeederTask(),
|
TasksSeederTask(),
|
||||||
]).init();
|
]).init();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
ProcessSignal.sigterm.watch().listen((signal) async {
|
ProcessSignal.sigterm.watch().listen((signal) async {
|
||||||
await isar.close();
|
try {
|
||||||
|
await isar.close();
|
||||||
|
} catch (e, s) {
|
||||||
|
log('Error closing Isar: $e', error: e, stackTrace: s);
|
||||||
|
print('Error closing Isar: $e');
|
||||||
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue