reload_flag=""
if [[ -n "${DEBUG}" ]]; then
reload_flag="--reload"
fi
if [[ -n "${WORKER_COUNT}" ]]; then
workers=${WORKER_COUNT}
else
workers=2
fi
gunicorn --workers ${workers} \
--bind 0.0.0.0:8000 \
${reload_flag} main.wsgi
Писали такие конструкции чтобы проверить наличие флага и сформировать команду правильно?
На самом деле можно сделать тоже самое проще. Для этого используются операторы условной подстановки, доступные в оболочках семейства POSIX.
:- для установки значений по умолчанию
${WORKER_COUNT:-2}
Если переменная не объявлена, то будет дефолтное значение 2.
:+ подставляет указанный текст, если переменная не пуста
${DEBUG:+--reload}
Если что-то есть в переменной то распечатается текст после символа +, в противном случае - ничего. Удобно для опциональных флагов, как в нашем примере.
Итого наш скрипт может выглядеть так:
gunicorn --workers ${WORKER_COUNT:-2} \
--bind 0.0.0.0:8000 \
${DEBUG:+--reload} main.wsgi
Есть еще два оператора.
:= не только подставить дефолтное значение, но и присвоить его переменной, если она пуста
# никаких переменных еще нет
VAL1=${VAL2:=hello}
# теперь доступны обе
echo $VAL1 $VAL2
# hello hello
:? остановить выполнение с ошибкой, если переменной нет.
echo ${MISS:?is required}
bash: MISS: is required
Код выхода будет 1.
#tricks#linux
Lassa fever (LF) initially presents like other common illnesses accompanied by a fever, such as malaria.
Healthcare workers are urged to remain vigilant.
Consider a #LF diagnosis when seeing patients showing symptoms of fever.
🔗Health Advisory
https://www.ncdc.gov.ng/news/507/lassa-fever-public-health-advisory
📜
Annual outbreaks of #LassaFever involve the infection and death of a loved family member, a spouse, a parent, and often seasoned healthcare workers and team members.
Our #LF health advisory provides measures through which health workers and the public can protect themselves.
🔗Read via https://www.ncdc.gov.ng/news/507/lassa-fever-public-health-advisory
📣JOIN IN
Our #LassaFever Research Colloquium is LIVE!
The colloquium aims to review the current situation and identify research priorities that will bring about a better understanding of #LF transmission using a One Health approach
🗓️TODAY, May 2nd, 2023
🕗 9:00 a.m. WAT
Register to join:
https://us06web.zoom.us/webinar/register/WN_N0qf8u_IR0W_8k1UaiCnaA
Healthcare workers should raise suspicion for patients with a history of contact with
➡️a probable/confirmed case of #LassaFever within 21 days of onset of fever
➡️body fluids/tissues of a patient with a febrile illness, symptoms & signs suggestive of #LF
🔗Read and share
https://www.ncdc.gov.ng/themes/common/docs/protocols/92_1547068532.pdf
Healthcare workers are advised to always be vigilant - lookout for symptoms of #LassaFever, not all fevers are malaria.
Any febrile illness that has not responded to the use of anti-malaria or antibiotics after 48 hrs should raise an index of suspicion for #LF.
#LassaFeverInfo