mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-14 04:01:16 +00:00
Add --secondary arg
This commit is contained in:
parent
236eee1774
commit
2f8ede54d7
4 changed files with 14 additions and 2 deletions
|
@ -216,6 +216,7 @@ Arguments passed to the process or set via environment variables are split into
|
||||||
| --api-keys-remote | Use this remote endpoint to query for valid API keys instead of using the local database | `Empty (use local db instead)` | LT_API_KEYS_REMOTE |
|
| --api-keys-remote | Use this remote endpoint to query for valid API keys instead of using the local database | `Empty (use local db instead)` | LT_API_KEYS_REMOTE |
|
||||||
| --get-api-key-link | Show a link in the UI where to direct users to get an API key | `Empty (no link shown on web ui)` | LT_GET_API_KEY_LINK |
|
| --get-api-key-link | Show a link in the UI where to direct users to get an API key | `Empty (no link shown on web ui)` | LT_GET_API_KEY_LINK |
|
||||||
| --shared-storage | Shared storage URI to use for multi-process data sharing (e.g. when using gunicorn) | `memory://` | LT_SHARED_STORAGE |
|
| --shared-storage | Shared storage URI to use for multi-process data sharing (e.g. when using gunicorn) | `memory://` | LT_SHARED_STORAGE |
|
||||||
|
| --secondary | Mark this instance as a secondary instance to avoid conflicts with the primary node in multi-node setups | `Primary node` | LT_SECONDARY |
|
||||||
| --load-only | Set available languages | `Empty (use all from argostranslate)` | LT_LOAD_ONLY |
|
| --load-only | Set available languages | `Empty (use all from argostranslate)` | LT_LOAD_ONLY |
|
||||||
| --threads | Set number of threads | `4` | LT_THREADS |
|
| --threads | Set number of threads | `4` | LT_THREADS |
|
||||||
| --metrics-auth-token | Protect the /metrics endpoint by allowing only clients that have a valid Authorization Bearer token | `Empty (no auth required)` | LT_METRICS_AUTH_TOKEN |
|
| --metrics-auth-token | Protect the /metrics endpoint by allowing only clients that have a valid Authorization Bearer token | `Empty (no auth required)` | LT_METRICS_AUTH_TOKEN |
|
||||||
|
|
|
@ -156,6 +156,11 @@ _default_options_objects = [
|
||||||
'default_value': 'memory://',
|
'default_value': 'memory://',
|
||||||
'value_type': 'str'
|
'value_type': 'str'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'name': 'SECONDARY',
|
||||||
|
'default_value': False,
|
||||||
|
'value_type': 'bool'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'name': 'LOAD_ONLY',
|
'name': 'LOAD_ONLY',
|
||||||
'default_value': None,
|
'default_value': None,
|
||||||
|
|
|
@ -154,6 +154,12 @@ def get_args():
|
||||||
metavar="<Storage URI>",
|
metavar="<Storage URI>",
|
||||||
help="Shared storage URI to use for multi-process data sharing (e.g. via gunicorn)",
|
help="Shared storage URI to use for multi-process data sharing (e.g. via gunicorn)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--secondary",
|
||||||
|
default=DEFARGS['SECONDARY'],
|
||||||
|
action="store_true",
|
||||||
|
help="Mark this instance as a secondary instance to avoid conflicts with the primary node in multi-node setups",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--load-only",
|
"--load-only",
|
||||||
type=operator.methodcaller("split", ","),
|
type=operator.methodcaller("split", ","),
|
||||||
|
|
|
@ -13,10 +13,10 @@ def setup(args):
|
||||||
if scheduler is None:
|
if scheduler is None:
|
||||||
scheduler = BackgroundScheduler()
|
scheduler = BackgroundScheduler()
|
||||||
|
|
||||||
if args.req_flood_threshold > 0:
|
if not args.secondary and args.req_flood_threshold > 0:
|
||||||
scheduler.add_job(func=forgive_banned, trigger="interval", minutes=10)
|
scheduler.add_job(func=forgive_banned, trigger="interval", minutes=10)
|
||||||
|
|
||||||
if args.api_keys and args.require_api_key_secret:
|
if not args.secondary and args.api_keys and args.require_api_key_secret:
|
||||||
scheduler.add_job(func=rotate_secrets, trigger="interval", minutes=30)
|
scheduler.add_job(func=rotate_secrets, trigger="interval", minutes=30)
|
||||||
|
|
||||||
scheduler.start()
|
scheduler.start()
|
||||||
|
|
Loading…
Reference in a new issue