fix: volume sync
This commit is contained in:
parent
948936dcff
commit
9698dc2115
89
app/cli.php
89
app/cli.php
|
@ -43,17 +43,44 @@ CLI::setResource('pools', function (Registry $register) {
|
|||
}, ['register']);
|
||||
|
||||
CLI::setResource('dbForConsole', function ($pools, $cache) {
|
||||
$dbAdapter = $pools
|
||||
->get('console')
|
||||
->pop()
|
||||
->getResource()
|
||||
;
|
||||
$sleep = 3;
|
||||
$maxAttempts = 5;
|
||||
$attempts = 0;
|
||||
$ready = false;
|
||||
|
||||
$database = new Database($dbAdapter, $cache);
|
||||
do {
|
||||
$attempts++;
|
||||
try {
|
||||
// Prepare database connection
|
||||
$dbAdapter = $pools
|
||||
->get('console')
|
||||
->pop()
|
||||
->getResource();
|
||||
|
||||
$database->setNamespace('console');
|
||||
$dbForConsole = new Database($dbAdapter, $cache);
|
||||
$dbForConsole->setNamespace('console');
|
||||
|
||||
return $database;
|
||||
// Ensure tables exist
|
||||
$collections = Config::getParam('collections', []);
|
||||
$last = \array_key_last($collections);
|
||||
|
||||
if (!($dbForConsole->exists($dbForConsole->getDefaultDatabase(), $last))) { /** TODO cache ready variable using registry */
|
||||
throw new Exception('Tables not ready yet.');
|
||||
}
|
||||
|
||||
$ready = true;
|
||||
} catch (\Exception $err) {
|
||||
Console::warning($err->getMessage());
|
||||
$pools->get('console')->reclaim();
|
||||
sleep($sleep);
|
||||
}
|
||||
} while ($attempts < $maxAttempts);
|
||||
|
||||
if (!$ready) {
|
||||
throw new Exception("Console is not ready yet. Please try again later.");
|
||||
}
|
||||
|
||||
return $dbForConsole;
|
||||
}, ['pools', 'cache']);
|
||||
|
||||
CLI::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, $cache) {
|
||||
|
@ -165,50 +192,4 @@ $cli
|
|||
Console::error($error->getMessage());
|
||||
});
|
||||
|
||||
$cli
|
||||
->init()
|
||||
->inject('pools')
|
||||
->inject('cache')
|
||||
->action(function (Group $pools, Cache $cache) {
|
||||
$maxAttempts = 5;
|
||||
$sleep = 3;
|
||||
|
||||
$attempts = 0;
|
||||
$ready = false;
|
||||
|
||||
do {
|
||||
$attempts++;
|
||||
|
||||
try {
|
||||
$pools->get('console')->reclaim();
|
||||
|
||||
// Prepare database connection
|
||||
$dbAdapter = $pools
|
||||
->get('console')
|
||||
->pop()
|
||||
->getResource();
|
||||
|
||||
$dbForConsole = new Database($dbAdapter, $cache);
|
||||
$dbForConsole->setNamespace('console');
|
||||
|
||||
// Ensure tables exist
|
||||
$collections = Config::getParam('collections', []);
|
||||
$last = \array_key_last($collections);
|
||||
|
||||
if (!($dbForConsole->exists($dbForConsole->getDefaultDatabase(), $last))) {
|
||||
throw new Exception('Tables not ready yet.');
|
||||
}
|
||||
|
||||
$ready = true;
|
||||
} catch (\Exception $err) {
|
||||
Console::warning($err->getMessage());
|
||||
sleep($sleep);
|
||||
}
|
||||
} while ($attempts < $maxAttempts);
|
||||
|
||||
if (!$ready) {
|
||||
throw new Exception("Console is not ready yet. Please try again later.");
|
||||
}
|
||||
});
|
||||
|
||||
$cli->run();
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6aa50b8b96b7941a710fe097f3f4d3a74f1eb823
|
||||
Subproject commit 4e2cecefb571104f0dbbe5a578729f0e17a10242
|
|
@ -769,6 +769,19 @@ services:
|
|||
- 9506:8080
|
||||
networks:
|
||||
- appwrite
|
||||
|
||||
# appwrite-volume-sync:
|
||||
# entrypoint: volume-sync
|
||||
# <<: *x-logging
|
||||
# container_name: appwrite-volume-sync
|
||||
# image: appwrite-dev
|
||||
# command:
|
||||
# - --source=/data/src/ --destination=/data/dest/ --interval=10
|
||||
# networks:
|
||||
# - appwrite
|
||||
# # volumes: # Mount the rsync source and destination directories
|
||||
# # - /nfs/config:/data/src
|
||||
# # - /storage/config:/data/dest
|
||||
|
||||
# redis-commander:
|
||||
# image: rediscommander/redis-commander:latest
|
||||
|
|
Loading…
Reference in a new issue