argosopentech / LibreTranslate-init

Shell scripts to install LibreTranslate
MIT License
55 stars 17 forks source link

How to use params #15

Closed manuelkamp closed 1 year ago

manuelkamp commented 1 year ago

I'd like to use params for libretranslate, but I do not know where to add them. If I add them to the end of this line like that, it fails to start:

ExecStart=/home/libretranslate/LibreTranslate/env/bin/gunicorn --workers 3 --bind unix:libretranslate.sock -m 007 wsgi:app --api-keys

I also tried (and failed) with that:

ExecStart=/home/libretranslate/LibreTranslate/env/bin/gunicorn --workers 3 --bind unix:libretranslate.sock -m 007 wsgi:app --env LT_API_KEYS

manuelkamp commented 1 year ago

Ok, I found out somehow, but it just works with this single argument:

ExecStart=/home/libretranslate/LibreTranslate/env/bin/gunicorn --workers 3 --bind unix:libretranslate.sock -m 007 wsgi:app(api_keys=True)

If I try to set more arguments, it fails again:

ExecStart=/home/libretranslate/LibreTranslate/env/bin/gunicorn --workers 3 --bind unix:libretranslate.sock -m 007 wsgi:app(api_keys=True,require-api-key-origin=True,req-limit=0,get-api-key-link=True)

PJ-Finlay commented 1 year ago

I think this is the format:

gunicorn --bind 0.0.0.0:5000 'wsgi:app(api_keys=True, ssl=True, load_only=["en","es","ar"])'

https://community.libretranslate.com/t/trying-to-set-up-dockerfile-dont-know-syntax/202/2

manuelkamp commented 1 year ago

Thank you, but that did not help me, since that is already the same format I used in my last attempt anyways. I added single quotes, but no success. This fails:

ExecStart=/home/libretranslate/LibreTranslate/env/bin/gunicorn --workers 3 --bind unix:libretranslate.sock -m 007 'wsgi:app(api_keys=True, require-api-key-origin=True, req-limit="0", get-api-key-link=True)'

it fails also with just two args like this: ExecStart=/home/libretranslate/LibreTranslate/env/bin/gunicorn --workers 3 --bind unix:libretranslate.sock -m 007 'wsgi:app(api_keys=True, get-api-key-link=True)'

It only works with one param like this: ExecStart=/home/libretranslate/LibreTranslate/env/bin/gunicorn --workers 3 --bind unix:libretranslate.sock -m 007 'wsgi:app(api_keys=True)'

PJ-Finlay commented 1 year ago

I'm not sure what the issue is here. I posted on the forum to see if anyone else knows.

https://community.libretranslate.com/t/adding-libretranslate-params-with-gunicorn/570

manuelkamp commented 1 year ago

Thank you very much.

OK, so the suggestion there with using underscores got me a thing closer. I found out, that some of the types are incorrect used by me (because they are not documented anywhere). So, in case anyone else comes upon this issue:

api_keys: Boolean (like api_keys=True) req_limit: int number (with quotes - like req_limit="5") batch_limit: int number (with quotes - like batch_limit="2") get_api_key_link: string (provide your OWN URL, there is no builtin function to retrieve API-keys - like get_api_key_link="https://yourapiurl.com") require_api_key_origin: string (??? I thought you can provide there your fqdn and bypass the API-key requirement for users browsing on the UI, but that does not work-at least not if you are running behind a reverse proxy like i do - what i saw on a docker-compose file of a bug report, require_api_key_origin=True does not work for me either, but seemed to work for this person)