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
👆 Propheta living up to its name yet again 🔮
#SPKUSDT reached 9th TP!
Signal from our VIP CLUB channel!
Feels good to be a Propheta VIP, man... 🏖ACCESS TO MANUAL TRADING for 70usdt/month
👉 We will keep posting about how we earn money. Will you keep watching how someone else does it, or start earning yourself? Subscribe using our telegram bot: t.me/ProphetaAdmin_bot
Register and get bonuses up to $6,000
Binance | OKX | ByBit👈🏻click!
#trading#autotrading#bitcoin
👆 Propheta living up to its name yet again 🔮
#SPKUSDT has just reached 9th TP in the VIP CLUB channel!!!👍
$432 in profits with a 5% entry and a $1000 deposit!
ACCESS TO MANUAL TRADING for 70usdt/month
👉 Get dozens of signals like these daily!
Subscribe now >>> t.me/ProphetaAdmin_bot
Register and get bonuses up to $6,000
Binance | OKX | ByBit👈🏻click!
#trading#buyeth#CryptoSignal
👆 Propheta living up to its name yet again 🔮
#SPKUSDT has achieved 9th TP in 14 hours in our VIP HTL channel!
You could've earned $304 with a 5% entry and a $1000 deposit!
Feels good to be a Propheta VIP, man... 🏖ACCESS TO MANUAL TRADING for 70usdt/month
💰Turn data into gains with Propheta AI Analyzer: deep AI analysis spots trends with surgical precision, tweaks in seconds to your goals, and pair hunting pumps your trading to the next level — this is the evolution of the game! GET THE ACCESS
Register and get bonuses up to $6,000
Binance | OKX | ByBit👈🏻click!
#AItrading#cryptoexchange#bitcoinnews
👀 Well, would you look at that! 👆
#SPKUSDT reached 9th TP in under 58 minutes!
Signal from our VIP HTL channel!
Easy $303 with a 5% entry and a $1000 deposit!
ACCESS TO MANUAL TRADING for 70usdt/month
👉 Looking at those reports and can't believe what you're seing?
Go to our reports channel and audit us! @propheta_reports
Register and get bonuses up to $6,000
Binance | OKX | ByBit👈🏻click!
#cryptocurrency#tradingindicator#bitcoinnews
#SPK did 114% massive rally by breaking out from the bottom accumulation zone along with #Upbit SPOT listing!! Congrats traders who bought on time!!
$SPK #SPKUSDT
https://x.com/CryptoBull_360/status/2046058078567845980?s=20