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
🎉 Exciting Partnership Announcement
We're thrilled to introduce our first official partner for the SingSing SocialFi SDK: Cowtopia🐮!
Cowtopia, an innovative farming simulation game, will be the first to integrate our powerful SocialFi SDK. This collaboration marks a significant milestone as we prepare to revolutionize the Telegram mini-app ecosystem.
Stay tuned and see how Cowtopia will utilize our SDK to create an immersive and socially connected gaming experience.
Read more and open treasure at: X Post
#SingSingSDK#Cowtopia#TelegramGaming#SocialFi#FarmingSimulator#ComingSoon
🔥🎉 Prepare yourself for an unparalleled gaming experience with TonAge! 🎮
💥
😀
💯Bid farewell to losses and say hello to an assured 100% Return to Player (RTP) in TonAge! 💰
✨
😀⭐️ Launch into a world of electrifying gameplay, where each spin, move, and quest is brimming with exhilarating excitement!
💥📍
⚡️
😀 Driven by blockchain technology, TonAge guarantees fair play and transparent outcomes, ensuring you can game with absolute peace of mind! 😎
😀
💎
✨ Unlock legendary treasures, conquer epic challenges, and witness your virtual victories transform into real-world value with the TON cryptocurrency! It's the ultimate gaming revolution!
🎁
💎
🤝⭐️ Join a vibrant community of gamers, strategists, and treasure seekers from all corners of the globe. Share tips, challenge friends, and compete for the top position on the leaderboard! 📍
🎁Don't miss out on this groundbreaking opportunity! Embark on an adventure that guarantees 100% RTP and endless thrills!
💎https://bit.ly/3SlL8fq
#TonAge#TelegramGaming#100PercentRTP#BlockchainGaming#EarnTON