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
#FLM/USDT analysis :
#FLM is forming higher highs (HHs) and higher lows (HLs) along the trendline support. The price has recently swept through the swing low stop losses and is now expected to move upward, resuming its bullish direction to test the swing high resistance level.
TF : 2H
Entry : $0.0423
Target : $0.0445
SL : $0.0409
#FLM/USDT analysis :
#FLM is currently in a bearish trend on the higher time frame. A retracement towards the 200 EMA is anticipated as the price forms a higher high structure. It is expected to move upward and test previous highs.
TF : 1H
Entry : $0.0584
Target : $0.0636
SL : $0.0560
#FLM/USDT analysis :
#FLM is currently in a downtrend, trading below the 200 EMA. The price is consolidating sideways within a support and resistance zone. It is currently facing rejection at the resistance zone and is expected to decline from this point, testing the support zone.
TF : 1D
Entry : $0.0620
Target : $0.0500
SL : $0.0700
#FLM🧐
👉EMA Confluence
👉Failure Swing
👉MACD
The second chart fully and automatically generated by our algorithm.
All drawings are based on only mathematical values and calculations instead of emotions.
Interested?
Check out -> www.coinlegs.com / www.legslabs.com