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
⚡️JetTon Games: Exciting New Slots Arrived!
#JetTon#slots
JetTon Games has introduced new enticing slots including Starshine Crystals, Coin Express, and Fighter Pit, each offering unique features and high potential wins. Players can enjoy wilds, risk games, and bonus fights with impressive multipliers. Join the fun at JetTon Games and share your favorites in the comments!
Source: link
@tonlines
🔥1 week after Dragon's Call release and we got:
👾70,000players played
😮x1268max win
In celebration of this we redesign game cover in different art styles🎨, try to guess what those styles are!
#dragonscall#truelab#slots
Our new column - Panda news from Dragon's Call📰
Today we discuss Colombia's tax hike in gambling💔
What do you think of this format?🐼
#news#pandanews#slots#dragonscall
The World of Games Awaits
🎰Polistar Casino invites you to an exciting world of games! 🃏
From classics to the latest releases – our collection is designed to deliver vivid emotions and engaging leisure. Enjoy high-quality graphics and a user-friendly interface.
➡️ Explore the Polistar universe. Simple sign-up here:
[Polistar Casino]
#Sponsorship#CasinoPolistar#CasinoGames#Slots#NewCasino