mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-06-24 10:00:59 +00:00
Add --secondary arg
This commit is contained in:
parent
236eee1774
commit
2f8ede54d7
4 changed files with 14 additions and 2 deletions
|
@ -156,6 +156,11 @@ _default_options_objects = [
|
|||
'default_value': 'memory://',
|
||||
'value_type': 'str'
|
||||
},
|
||||
{
|
||||
'name': 'SECONDARY',
|
||||
'default_value': False,
|
||||
'value_type': 'bool'
|
||||
},
|
||||
{
|
||||
'name': 'LOAD_ONLY',
|
||||
'default_value': None,
|
||||
|
|
|
@ -154,6 +154,12 @@ def get_args():
|
|||
metavar="<Storage URI>",
|
||||
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(
|
||||
"--load-only",
|
||||
type=operator.methodcaller("split", ","),
|
||||
|
|
|
@ -13,10 +13,10 @@ def setup(args):
|
|||
if scheduler is None:
|
||||
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)
|
||||
|
||||
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.start()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue