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
🔥 Pikaio Airdrop
Pikaio aims to be the first launchpad on the #Bitlayer network.
👉https://pika.io/points/fS7uzk
(If there are items)
1️⃣Wallet example (Metamask,OKXv.b)
2️⃣Connect your Twitter account and do the Rt, Like task.
3️⃣Connect Telegram and join the telegram channel.
That's it, the current number of tasks.
📌 There will be special rewards for early events
1.Early Token Airdrops: Catch the moment to receive airdrops of upcoming ecosystem tokens!
🆕 BitLayer is now live on TokenPocket.
🟧BitLayer is the first Bitcoin security-equivalent Layer 2 based on the BitVM paradigm.
🚀How to create/import a #BitLayer wallet on #TokenPocket Mobile Wallet and Chrome Extension Wallet?
Guide👉https://help.tokenpocket.pro/en/wallet-operation/how-to-create-a-wallet/bitlayer
💙Download #TokenPocket, create your BitLayer Wallet, and stay tuned to the upcoming campaign! 🔥
👉https://tokenpocket.pro
👉https://extension.tokenpocket.pro
🎇Happy #TP6Anni!!
💙Join and win 50 BitlayerLabs Lucky Helmet NFT Whitelists Giveaway on Galxe!
👉https://app.galxe.com/quest/TokenPocket/GCddyth8TC
🟧Bitlayer Lucky Helmet is the official NFT launched by BitlayerLabs, a symbol of identity representing the contributions of builders in the Bitlayer community.
#TP6Anni#TokenPocket#Bitlayer
🏅 Predict & Earn 50K Points Daily! 💰
🏀 Premier League Week 1 Prediction: Who will win—Man United vs. Fulham, Arsenal vs. Wolves?
👉 How to Enter:
- RT & comment with a screenshot of your prediction
- Drop your Bitlayer address
🎯 5 winners will be randomly chosen to win 10K points each tomorrow!
Join Now: http://bitlayer.org/guess-to-earn
#Preditctowin#Bitlayer#Giveaway
Retweet:
https://x.com/bitlayerlabs/status/1824353973127745582?s=46
🟧 Enjoy the complete BitlayerLabs Ecosystem on your TokenPocket Wallet!
👉https://tokenpocket.pro
You can easily
✅Bridge #Bitcoin to Bitlayer
✅Find the trending DApps on Bitlayer
✅Track the real-time market #NFA
✅Manage your NFTs #LuckyHelmet
🔸and more in the near future!
Ready your #Bitlayer Wallet on TokenPocket and stay tuned for more!
👉https://help.tokenpocket.pro/en/wallet-operation/how-to-create-a-wallet/bitlayer