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
#ONE/USDT analysis :
#ONE has broken out of the trendline following a bounce from the support zone, accompanied by a strong volume candle. The price is expected to continue its bullish momentum soon and test the previous highs. A potential gain of +1100% is anticipated from the current level.
TF : 1M
Entry : $0.03000
Target : $0.37897
SL : $0.02100
#ONE/USDT analysis :
#ONE is currently forming a structure of higher highs (HHs) and higher lows (HLs) above the 200 EMA. The price is anticipated to sustain its momentum and reach new highs. Wait for a pullback to enter long positions.
TF : 1H
Entry : $0.0113
Target : $0.0122
SL : $0.0108
#ONE/USDT analysis :
#ONE is currently consolidating sideways within the support and resistance zone. At the moment, the price is bouncing off the support zone and is expected to test the resistance zone.
TF : 4H
Entry : $0.0104
Target : $0.0110
SL : $0.0100
#ONE/USDT analysis -
#ONE is in a downtrend making lower lows (LLs) and lower highs (LHs). The price is currently facing resistance and is expected to be rejected from there, continuing its bearish momentum to test previous lows.
TF : 4h
Entry : $0.0150
Target : $0.0133
SL : $0.0162