From 95033636cd80b3ec306ab4efde9103db9adb3e2f Mon Sep 17 00:00:00 2001 From: "Abdulmhsen B. A. A" Date: Mon, 25 Apr 2022 01:04:28 +0300 Subject: [PATCH] Allow the importing on unwatched items via Scheduled tasks. --- README.md | 6 ++++-- config/config.php | 5 ++++- docker/files/entrypoint.sh | 3 --- src/Commands/State/ExportCommand.php | 3 +-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 965295d2..34f4c59d 100644 --- a/README.md +++ b/README.md @@ -136,13 +136,13 @@ healthy `GUIDS <> serverInternalID mapping` relations. To manually export your watch state back to servers you can run the following command ```bash -$ docker exec -ti watchstate console state:export --mapper-preload -vvr +$ docker exec -ti watchstate console state:export -vvr ``` to sync specific server/s, use the `--servers-filter` which accept comma seperated list of server names. ```bash -$ docker exec -ti watchstate console state:export -vvr --mapper-preload --servers-filter 'server1,server2' +$ docker exec -ti watchstate console state:export -vvr --servers-filter 'server1,server2' ``` To enable the export scheduled task set the value of `WS_CRON_EXPORT` to `1`. By default, we run export every 90 @@ -316,6 +316,7 @@ None that we are aware of. - (string) `WS_LOGGER_SYSLOG_NAME` What name should logs be under. - (int) `WS_CRON_IMPORT` enable import scheduled task. - (string) `WS_CRON_IMPORT_AT` cron expression timer. +- (bool) `WS_CRON_IMPORT_UNWATCHED` Allow the import task to import unwatched items. Defaults to `false`. - (int) `WS_CRON_EXPORT` enable export scheduled task. - (string) `WS_CRON_EXPORT_AT` cron expression timer. - (int) `WS_CRON_PUSH` enable push scheduled task. @@ -330,6 +331,7 @@ None that we are aware of. - (int) `WS_NO_CHOWN` do not change ownership of `/config` inside container. - (int) `WS_DISABLE_HTTP` disable included http server. +- (int) `WS_DISABLE_CRON` disable included task scheduler. - (int) `WS_UID` Container user ID - (int) `WS_GID` Container group ID diff --git a/config/config.php b/config/config.php index d43c5c32..130c48bf 100644 --- a/config/config.php +++ b/config/config.php @@ -172,7 +172,6 @@ return (function () { Task::RUN_AT => (string)env('WS_CRON_EXPORT_AT', '30 */1 * * *'), Task::COMMAND => '@state:export', Task::ARGS => [ - '--mapper-preload' => null, '-v' => null, ] ], @@ -205,5 +204,9 @@ return (function () { ], ]; + if (true === (bool)env('WS_CRON_IMPORT_UNWATCHED', false)) { + $config['tasks'][ImportCommand::TASK_NAME][Task::ARGS]['--import-unwatched'] = null; + } + return $config; })(); diff --git a/docker/files/entrypoint.sh b/docker/files/entrypoint.sh index 9147b37e..1005c534 100755 --- a/docker/files/entrypoint.sh +++ b/docker/files/entrypoint.sh @@ -6,9 +6,6 @@ WS_GID=${WS_GID:-1000} WS_NO_CHOWN=${WS_NO_CHOWN:-0} WS_DISABLE_HTTP=${WS_DISABLE_HTTP:-0} WS_DISABLE_CRON=${WS_DISABLE_CRON:-0} -WS_CRON_IMPORT=${WS_CRON_IMPORT:-0} -WS_CRON_PUSH=${WS_CRON_PUSH:-0} -WS_CRON_EXPORT=${WS_CRON_EXPORT:-0} set -u diff --git a/src/Commands/State/ExportCommand.php b/src/Commands/State/ExportCommand.php index fadb6272..e4d828ec 100644 --- a/src/Commands/State/ExportCommand.php +++ b/src/Commands/State/ExportCommand.php @@ -74,7 +74,6 @@ class ExportCommand extends Command InputOption::VALUE_NONE, 'Ignore date comparison, and update server watched state to match database.' ) - ->addOption('mapper-preload', null, InputOption::VALUE_NONE, 'Preload Mapper database into memory.') ->addOption('config', 'c', InputOption::VALUE_REQUIRED, 'Use Alternative config file.'); } @@ -157,7 +156,7 @@ class ExportCommand extends Command return self::FAILURE; } - if (count($list) >= 1 && $input->getOption('mapper-preload')) { + if (count($list) >= 1) { $this->logger->info('Preloading all mapper data.'); $this->mapper->loadData(); $this->logger->info('Finished preloading mapper data.');