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
🦉🚨Node Upgrade🚨🦉
Tearline AI app just rolled out a node upgrade! 🔥 This update will revamp power & compute calculations, ensuring a more equitable and transparent reward system.
Embrace fairer perks and a stronger #Tearline.
Plus, enjoy an easier-to-use sharing button in chat!
Details👉https://medium.com/@tearlineAI/tearline-node-upgrade-and-system-changes-3053e78abee1
🌐✨#Tearline just dropped on the 🔝 AI tool directories — Toolify.ai & TopAI.tools!
🔗 Toolify: toolify.ai/tool/tearline
🔗 TopAI: topai.tools/t/tearline
We’re blowing up in Web3 & tech.
What are you waiting for?
Start earning more today! 💸
Watch out, Tearline is leveling up - Your chat mate just got a turbo boost! 🦉💬
✅Chat history - securely stored
✅Full-context convo - like talking to real person
✅Multi-window chat - as smooth as cutting melting butt
✅Multi-language support, sure thing!
🇰🇷🇯🇵🇷🇺Korean, Japanese, Russian, Traditional Chinese speakers🤖️#Tearline now speaks the same language with you!
Let's rock those chats!
Play free, Earn your Power & Compute to secure airdrops! 🔐💫
Exciting news! 🦉#Tearline Bot will soon be seamlessly available on Telegram. 🚀
1. Access a real-time Web3 research engine instantly.
2. Get daily consulting to enhance your trading assistant.
3. Grab community points by joining now! http://t.me/tearlinexyz
Stay tuned for expanding service & ecosystem support📈✨
📢Tearline Points Program Update🚀
🔹 Phase 1 Points Snapshot Completed! 🎯 A snapshot of Phase 1 points will be taken on March 20 at 10:00 AM (UTC+8). These points have been securely recorded and will be a key reference for future TGE airdrops.
🔹 Phase 2 Starts NOW! 🌟 The next phase of the points program will officially begin on March 20 at 10:00 AM (UTC+8). You can now earn points across both the Mini App and the Web version. Log in with your Telegram account to seamlessly continue your journey.
Start earning today 👉https://www.tearline.io
📖 Learn more on Medium: https://medium.com/tearline/the-future-of-web3-interaction-tearlines-ai-and-multi-chain-strategy-aac34e5c856a
#Web3#Tearline#Airdrop#BNBChain