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
🚀BubbleMaps (BMT) Airdrop is LIVE on Binance! 🎉
Earn FREE $BMT with Retroactive BNB SimpleEarn Subscriptions! If you held BNB in Simple Earn (Flexible/Locked) or On-Chain Yields (March 2 - 6, 2025) you may qualify! 🎁
🔥 Why BubbleMaps?
✔️ Track token movements & uncover hidden links 🔍
✔️ Integrated with CoinGecko, DexScreener & more 💡
✔️ BubbleMaps V2 unlocks new features with $BMT🚀
📈$BMT Trading Pairs on Binance:
🔹 BMT/USDT | BMT/USDC | BMT/BNB | BMT/FDUSD | BMT/TRY
⚙️ How to Participate?
📥Check Your Eligibility & Claim Here:
👉Register & Claim Now
📢Stay Updated & Join Our Community:
🔗BubbleMaps Official Telegram
®Note - Please do your own research (DYOR) before joining to any airdrops project, also airdrop is 100% free. Don't send any fee or penny for receiving airdrop tokens
#BubbleMaps#BMT#Binance#Airdrop#Crypto
Simplifying Processes: A Billion-Dollar Idea
A new startup aims to simplify image and video management, outperforming Dropbox. This innovation has attracted nearly $70 million in investments, capitalizing on a $2 trillion creative economy. Additionally, Bubblemaps has launched its BMT token on Solana, offering on-chain analytics and community governance, hinting at a potential airdrop. Deribit, a major crypto derivatives exchange, is exploring acquisition offers, valued between $4-5 billion, with Kraken showing interest.
#Startup#Dropbox#Investment#CreativeEconomy#Bubblemaps#BMT#Token#Solana#Crypto#ETFs#Derivatives#Kraken#Airdrop#VC#AI#Blockchain#Innovation#Finance
🚀 Crypto Analyst Manya Releases Research Tool Rankings
Crypto analyst manya has released a ranking of personal research tools. According to ChainCatcher, the rankings categorize tools into different levels based on their effectiveness. The S-tier includes Dune and frontrun.pro, while the A-tier features Coinglass, RootData, Drop, MetaSleuth, and DefiLlama. B-tier tools comprise Arkham, Bubblemaps, Dexscreener, Surf, Nansen, and CoinMarketCap. C-tier tools include Cryptorank and others.
#CryptoAnalyst#ResearchTools#CryptoRanking#Dune#frontrunpro#Coinglass#RootData#Drop#MetaSleuth#DefiLlama#Arkham#Bubblemaps#Dexscreener#Surf#Nansen#CoinMarketCap#Cryptorank