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
Girls’ Meeting at Green University!
✅On October 23, a special gathering was held for our female students, focusing on etiquette, moral values, and personal growth.
🔄The event also featured a psychological training session that helped participants build confidence and strengthen communication skills.
#GreenUniversity#StudentLife#GirlsMeeting#PersonalDevelopment
✉️[email protected]
☎️ +998 55 512 00 77
📍Location
🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube
📖Title : This Too Shall Pass
✍️Author : Julia Samuel
⭐️Rating : 3.72/5 (Goodreads)
📆Published : Mar 05, 2020
————————————————
Summary:This Too Shall Pass by Julia Samuel is a profound exploration of how humans cope with change and emotional upheaval. Drawing on her extensive experience as a psychotherapist, Samuel presents twelve moving and deeply personal case studies that cover themes such as grief, relationships, identity, and trauma. Each story reveals how people struggle with, resist, and ultimately adapt to change. Through compassionate storytelling and psychological insight, Samuel illustrates that while change is inevitable and often painful, it also offers opportunities for growth and healing. The book is a comforting, insightful guide for anyone navigating life’s unpredictable transitions and emotional challenges.
————————————————
#nonfiction#psychology#selfhelp#personaldevelopment@Bookslibraryofficial@free_novellas@the_ancient_library
Diversity & Inclusion
There is a significant relationship between competitive profit gains and diversity.
Companies with gender, ethnic and racial diversity are at least 15 percent more likely to experience above-average financial returns.
#Wednesday#Day-3
#personalDevelopment#selfhelp#leadership#Growth#Teambuild
Read 📚:- https://t.me/Think_CreativeHub
$5.4M Funding for Tenor
Tenor has raised $5.40 million on December 19, 2024. This platform enables managers to rehearse difficult conversations with realistic voice AI characters and receive instant feedback for improvement.
#Funding#AI#VoiceAI#Management#Feedback#Conversations#Tech#Startup#Investment#Training#Innovation#Leadership#Simulation#Dialogue#PersonalDevelopment#Business#Growth#Application#Software#Tenor