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
#CELR/USDT analysis :
#CELR is currently forming a triangle pattern. A breakout from this pattern is anticipated, with the price expected to test previous highs. A long entry is recommended upon a breakout above the $0.02130 level.
TF : 1D
Entry : $0.02130
Target : $0.03180
SL : $0.01695
#CELR/USDT analysis :
#CELR is currently in a downtrend, trading below the 200 EMA. The price is currently facing resistance in this zone. It is expected to reverse from this point and continue its bearish trend to test previous lows. Wait for a breakout below the $0.01114 level to consider going short.
TF : 4H
Entry : $0.01114
Target : $0.01014
SL : $0.01169
#CELR/USDT analysis :
#CELR is in a downtrend, trading below the 200 EMA. The price is forming LLs and LHs structure. Before continuing its bearish momentum, the price is expected to experience a pullback and test the resistance zone. Wait for the pullback for a short entry.
TF : 1H
Entry : $0.01142
Target : $0.01043
SL : $0.01177
#CELR/USDT analysis -
#CELR is in a downtrend, trading below the 200 EMA. The price is currently approaching a resistance zone. It is expected to be rejected from there and continue the bearish momentum towards the previous lows.
TF : 4h
Entry : $0.0157
Target : $0.0129
SL : $0.0164
#CELR/USDT BUY SETUP
CELR has broken out of the descending triangle and is currently testing it. A successful test will confirm a bullish move. Get ready for takeoff. 🚀