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
🎉🎉 Celebrate with us the impressive metrics within 🔟 days of Beta Launch🚀📈:
- 30K active users from 50 countries
- 10.2K smart alert configs are set
- 1.5M interactive maps are visualized
🌐🔗 We're honoured to harness #AI and #Onchaindata to empower our users for success!
🎯There is still a chance to share our 🎁$2,000🎁 reward pool and win the Beta Access Code!!
🎮Jump in our Zealy quest board now! We are distributing the code every week to highly engaging members. 🍀👇
https://zealy.io/c/spotonchain/questboard
🚀 Bitcoin's Potential Bear-Market 'Iron Bottom' Predicted by Analyst
A CryptoQuant analyst has projected that Bitcoin might establish a bear-market 'iron bottom' within the $55,000–$60,000 range by the end of 2026. According to NS3.AI, this prediction is grounded in on-chain indicators, notably the MVRV Z-score, which has moderated but remains above negative levels.
#Bitcoin#Crypto#BearMarket#CryptoAnalysis#MVRV#OnChainData#CryptoPredictions#BTC
🚀 Satoshi Protocol Layer2 Settlement Network Launches with Upgrades
The Satoshi Protocol Layer2 settlement network officially launched on April 6, introducing enhancements in on-chain data statistics and computational capabilities. According to ChainCatcher, the Layer2 network now supports deep cumulative calculations on-chain, allowing for a more accurate reflection of team sizes and business data, thereby improving processing efficiency in complex scenarios.
In terms of governance, the protocol has transferred core permissions to a multi-signature contract and adopted a dual-track governance model, with developers and core community members each holding 50% of the decision-making power. The execution threshold is set at 65%, further enhancing decentralization.
This upgrade marks the protocol's transition towards community autonomy, providing a reference for technology and governance in the DeFi sector.
#SatoshiProtocol#Layer2#Blockchain#DeFi#Governance#Decentralization#OnChainData#NetworkLaunch#Crypto#MultiSignature#ProtocolUpgrade#CommunityAutonomy