feat: add new rsync worker
This commit is contained in:
parent
1b776f7fdc
commit
8ced55bf46
6 changed files with 81 additions and 17 deletions
|
@ -271,6 +271,7 @@ RUN \
|
|||
&& apk add --no-cache \
|
||||
libstdc++ \
|
||||
certbot \
|
||||
rsync \
|
||||
brotli-dev \
|
||||
yaml-dev \
|
||||
imagemagick \
|
||||
|
@ -332,6 +333,7 @@ RUN mkdir -p /storage/uploads && \
|
|||
# Executables
|
||||
RUN chmod +x /usr/local/bin/doctor && \
|
||||
chmod +x /usr/local/bin/maintenance && \
|
||||
chmod +x /usr/local/bin/certificate-sync && \
|
||||
chmod +x /usr/local/bin/usage && \
|
||||
chmod +x /usr/local/bin/install && \
|
||||
chmod +x /usr/local/bin/migrate && \
|
||||
|
|
|
@ -14,6 +14,7 @@ $cli = new CLI();
|
|||
|
||||
include 'tasks/doctor.php';
|
||||
include 'tasks/maintenance.php';
|
||||
include 'tasks/rsync.php';
|
||||
include 'tasks/install.php';
|
||||
include 'tasks/migrate.php';
|
||||
include 'tasks/sdks.php';
|
||||
|
|
|
@ -35,6 +35,7 @@ foreach (
|
|||
realpath(__DIR__ . '/../vendor/symfony'),
|
||||
realpath(__DIR__ . '/../vendor/mongodb'),
|
||||
realpath(__DIR__ . '/../vendor/utopia-php/websocket'), // TODO: remove workerman autoload
|
||||
realpath(__DIR__ . '/../vendor/utopia-php/cache'), // TODO: remove workerman autoload
|
||||
] as $key => $value
|
||||
) {
|
||||
if ($value !== false) {
|
||||
|
|
42
app/tasks/rsync.php
Normal file
42
app/tasks/rsync.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
global $cli;
|
||||
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Validator\Integer;
|
||||
use Utopia\Validator\Text;
|
||||
|
||||
$cli
|
||||
->task('rsync')
|
||||
->desc('Runs rsync to sync certificates between the storage mount and traefik.')
|
||||
->param('source', null, new Text(255), 'Source path to sync from.', false)
|
||||
->param('destination', null, new Text(255), 'Destination path to sync to.', false)
|
||||
->param('interval', null, new Integer(true), 'Interval to run rsync', false)
|
||||
->action(function ($source, $destination, $interval) {
|
||||
|
||||
Console::title('RSync V1');
|
||||
Console::success(APP_NAME . ' rsync process v1 has started');
|
||||
|
||||
Console::loop(function () use ($interval, $source, $destination) {
|
||||
$time = DateTime::now();
|
||||
|
||||
Console::info("[{$time}] Executing rsync every {$interval} seconds");
|
||||
Console::info("Syncing between $source and $destination");
|
||||
|
||||
if (!file_exists($source)) {
|
||||
Console::error('Source directory does not exist. Skipping ... ');
|
||||
return;
|
||||
}
|
||||
|
||||
$stdin = "";
|
||||
$stdout = "";
|
||||
$stderr = "";
|
||||
|
||||
Console::execute("rsync -av $source $destination", $stdin, $stdout, $stderr);
|
||||
Console::success($stdout);
|
||||
Console::error($stderr);
|
||||
|
||||
}, $interval);
|
||||
});
|
3
bin/certificate-sync
Normal file
3
bin/certificate-sync
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
php /usr/src/code/app/cli.php rsync $@
|
|
@ -85,7 +85,7 @@ services:
|
|||
- ./dev:/usr/local/dev
|
||||
- ./vendor/utopia-php/database:/usr/src/code/vendor/utopia-php/database
|
||||
depends_on:
|
||||
- mariadb
|
||||
- mysql
|
||||
- redis
|
||||
# - clamav
|
||||
entrypoint:
|
||||
|
@ -204,7 +204,7 @@ services:
|
|||
- ./app:/usr/src/code/app
|
||||
- ./src:/usr/src/code/src
|
||||
depends_on:
|
||||
- mariadb
|
||||
- mysql
|
||||
- redis
|
||||
environment:
|
||||
- _APP_ENV
|
||||
|
@ -235,7 +235,7 @@ services:
|
|||
- ./src:/usr/src/code/src
|
||||
depends_on:
|
||||
- redis
|
||||
- mariadb
|
||||
- mysql
|
||||
environment:
|
||||
- _APP_ENV
|
||||
- _APP_OPENSSL_KEY_V1
|
||||
|
@ -264,7 +264,7 @@ services:
|
|||
- ./src:/usr/src/code/src
|
||||
depends_on:
|
||||
- redis
|
||||
- mariadb
|
||||
- mysql
|
||||
- request-catcher
|
||||
environment:
|
||||
- _APP_ENV
|
||||
|
@ -287,7 +287,7 @@ services:
|
|||
- appwrite
|
||||
depends_on:
|
||||
- redis
|
||||
- mariadb
|
||||
- mysql
|
||||
volumes:
|
||||
- appwrite-uploads:/storage/uploads:rw
|
||||
- appwrite-cache:/storage/cache:rw
|
||||
|
@ -348,7 +348,7 @@ services:
|
|||
#- ./vendor/utopia-php/database:/usr/src/code/vendor/utopia-php/database
|
||||
depends_on:
|
||||
- redis
|
||||
- mariadb
|
||||
- mysql
|
||||
environment:
|
||||
- _APP_ENV
|
||||
- _APP_OPENSSL_KEY_V1
|
||||
|
@ -377,7 +377,7 @@ services:
|
|||
- ./src:/usr/src/code/src
|
||||
depends_on:
|
||||
- redis
|
||||
- mariadb
|
||||
- mysql
|
||||
environment:
|
||||
- _APP_ENV
|
||||
- _APP_OPENSSL_KEY_V1
|
||||
|
@ -405,7 +405,7 @@ services:
|
|||
- appwrite
|
||||
depends_on:
|
||||
- redis
|
||||
- mariadb
|
||||
- mysql
|
||||
volumes:
|
||||
- appwrite-config:/storage/config:rw
|
||||
- appwrite-certificates:/storage/certificates:rw
|
||||
|
@ -442,7 +442,7 @@ services:
|
|||
- ./src:/usr/src/code/src
|
||||
depends_on:
|
||||
- redis
|
||||
- mariadb
|
||||
- mysql
|
||||
- appwrite-executor
|
||||
environment:
|
||||
- _APP_ENV
|
||||
|
@ -488,7 +488,7 @@ services:
|
|||
- /tmp:/tmp:rw
|
||||
depends_on:
|
||||
- redis
|
||||
- mariadb
|
||||
- mysql
|
||||
- appwrite
|
||||
environment:
|
||||
- _APP_ENV
|
||||
|
@ -619,6 +619,21 @@ services:
|
|||
- _APP_MAINTENANCE_RETENTION_ABUSE
|
||||
- _APP_MAINTENANCE_RETENTION_AUDIT
|
||||
|
||||
appwrite-rsync:
|
||||
entrypoint: certificate-sync
|
||||
<<: *x-logging
|
||||
container_name: appwrite-rsync
|
||||
build:
|
||||
context: .
|
||||
restart: unless-stopped
|
||||
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
|
||||
|
||||
appwrite-usage-timeseries:
|
||||
entrypoint:
|
||||
- usage
|
||||
|
@ -637,7 +652,7 @@ services:
|
|||
- ./dev:/usr/local/dev
|
||||
depends_on:
|
||||
- influxdb
|
||||
- mariadb
|
||||
- mysql
|
||||
environment:
|
||||
- _APP_ENV
|
||||
- _APP_OPENSSL_KEY_V1
|
||||
|
@ -675,7 +690,7 @@ services:
|
|||
- ./dev:/usr/local/dev
|
||||
depends_on:
|
||||
- influxdb
|
||||
- mariadb
|
||||
- mysql
|
||||
environment:
|
||||
- _APP_ENV
|
||||
- _APP_OPENSSL_KEY_V1
|
||||
|
@ -715,14 +730,14 @@ services:
|
|||
- _APP_REDIS_USER
|
||||
- _APP_REDIS_PASS
|
||||
|
||||
mariadb:
|
||||
image: mariadb:10.7 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
container_name: appwrite-mariadb
|
||||
mysql:
|
||||
image: mysql:8.0.28-oracle # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
container_name: appwrite-mysql
|
||||
<<: *x-logging
|
||||
networks:
|
||||
- appwrite
|
||||
volumes:
|
||||
- appwrite-mariadb:/var/lib/mysql:rw
|
||||
- appwrite-mysql:/var/lib/mysql:rw
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
|
@ -886,7 +901,7 @@ networks:
|
|||
runtimes:
|
||||
|
||||
volumes:
|
||||
appwrite-mariadb:
|
||||
appwrite-mysql:
|
||||
appwrite-redis:
|
||||
appwrite-cache:
|
||||
appwrite-uploads:
|
||||
|
|
Loading…
Reference in a new issue