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
#SCRT is rebounding from the support trendline of a falling wedge pattern, showing early signs of recovery.
The 50MA is acting as a resistance barrier above the wedge, limiting upside for now.
A strong breakout of the wedge would confirm bullish momentum and could trigger a solid rally.
#SCRT/USDT analysis :
#SCRT is currently trading within a channel. The price is likely to move upward and test the channel's resistance. It is advisable to wait for a pullback to the support zone for a long entry, as the price is expected to continue its upward movement.
TF : 4h
Entry : $0.1958
Target : $0.2354
SL : $0.1793
#SCRT/USDT analysis :
#SCRT is in a downtrend, consistently trading below the 200 EMA. The price is currently trading in a resistance zone.
It is expected to be rejected from there and will soon continue its downward movement. Wait for the breakout of the $0.1960 level for a short entry; the previous lows will be the target.
TF : 30min
Entry : $0.1960
Target : $0.1742
SL : $0.2094
#SCRT result
1st target achieved in just 1 hour✅
One more quick profit 5%💰🤑
👉 More quick profit signals available in premium channel. Hurry up 🏃♂👇
☎️ Contact @MichaelStrategiesVip