feat: starter for maintenance task
This commit is contained in:
parent
84fb5387ab
commit
408ae68e7a
|
@ -93,7 +93,8 @@ ENV _APP_SERVER=swoole \
|
|||
_APP_FUNCTIONS_TIMEOUT=900 \
|
||||
_APP_FUNCTIONS_CONTAINERS=10 \
|
||||
_APP_SETUP=self-hosted \
|
||||
_APP_VERSION=$VERSION
|
||||
_APP_VERSION=$VERSION \
|
||||
_APP_MAINTENANCE_INTERVAL=10
|
||||
#ENV _APP_SMTP_SECURE ''
|
||||
#ENV _APP_SMTP_USERNAME ''
|
||||
#ENV _APP_SMTP_PASSWORD ''
|
||||
|
@ -155,6 +156,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/install && \
|
||||
chmod +x /usr/local/bin/migrate && \
|
||||
chmod +x /usr/local/bin/schedule && \
|
||||
|
|
|
@ -9,6 +9,7 @@ use Utopia\CLI\Console;
|
|||
$cli = new CLI();
|
||||
|
||||
include 'tasks/doctor.php';
|
||||
include 'tasks/maintenance.php';
|
||||
include 'tasks/install.php';
|
||||
include 'tasks/migrate.php';
|
||||
include 'tasks/sdks.php';
|
||||
|
|
19
app/tasks/maintenance.php
Normal file
19
app/tasks/maintenance.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
global $cli;
|
||||
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
|
||||
$cli
|
||||
->task('maintenance')
|
||||
->desc('Schedules maintenance tasks and publishes them to resque')
|
||||
->action(function () {
|
||||
$interval = App::getEnv('_APP_MAINTENANCE_INTERVAL', '');
|
||||
|
||||
for($i = 0; $i <= 10; ++$i){
|
||||
Console::log('Starting the maintenance worker every '.$interval.' seconds');
|
||||
sleep($interval);
|
||||
}
|
||||
|
||||
});
|
3
bin/maintenance
Normal file
3
bin/maintenance
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
php /usr/src/code/app/cli.php maintenance $@
|
|
@ -277,6 +277,22 @@ services:
|
|||
- _APP_SMTP_USERNAME
|
||||
- _APP_SMTP_PASSWORD
|
||||
|
||||
appwrite-maintenance:
|
||||
entrypoint: maintenance
|
||||
container_name: appwrite-maintenance
|
||||
build:
|
||||
context: .
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- appwrite
|
||||
depends_on:
|
||||
- redis
|
||||
- mariadb
|
||||
environment:
|
||||
- _APP_ENV
|
||||
- _APP_REDIS_HOST
|
||||
- _APP_REDIS_PORT
|
||||
|
||||
appwrite-schedule:
|
||||
entrypoint: schedule
|
||||
container_name: appwrite-schedule
|
||||
|
|
Loading…
Reference in a new issue