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
It might look a little confusing at first, but pay attention.
On this chart we have DXY, GOLD and BTC.
DXY, which is a representative chart of the USD, has an inverse relationship with GOLD and BTC.
This is because when the dollar is strong, big money moves into high interest bonds that are safe.
When the dollar weakens, big money moves into safe havens and riskier assets.
What we can firstly see on the chart is that every time DXY drops, GOLD almost instantly moves higher.
Secondly, we can see that BTC also moves higher, but it lags behind GOLD.
But that’s not the most interesting thing…
The most interesting thing here is that every single time DXY has entered a down trend, BTC has began its move between 133 days and 140 days later.
This time, that gives us an end of May date as to when BTC will begin its next true move higher.
It’s just facts, right there for you to see.
#CryptoSignal#Binance#PumpAlert#FuturesTrade
30 day PNL screenshot14 New tarde profit ✈️✈️If you're want this
Type profit in 7 days ..
✅ Don’t miss the next big move — join our VIP Premium Channel now!
📩 Contact: @Future3366
🚀 Real-time signals | Pump alerts | Future trades
#CryptoSignals#VIPAccess#BinanceFutures#PumpAlert#CryptoProfits