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
#LSK/USDT analysis :
#LSK is in a downtrend, trading below the 200 EMA and forming lower lows (LLs) and lower highs (LHs). The price is currently within a resistance zone, and it is anticipated to reverse from this level, resuming its bearish momentum to test lower price levels.
TF : 4h
Entry : $0.760
Target : $0.665
SL : $0.808
#LSK/USDT analysis :
#LSK has broken down and retested the resistance zone. The price is expected to bounce back from there and continue its bearish momentum to test the previous swing low.
TF : 4H
Entry : $0.825
Target : $0.745
SL : $0.878
📊#LSK is breakout the descending triangle with a descent volume. It got rejected from the MA 200 and currently, facing the Ichimoku cloud.✅
💬A candle close above the triangle or a break above the MA 200 would be the confirmation of a bullish rally.
❄️@signals_bitcoin_crypto❄️
❄️@Shadow_support0o❄️
#LSK/USDT analysis -
#Lisk is experiencing a corrective pullback, creating a quick scalp opportunity on the buy side. Price is following a trendline. It is expected to bounce off from there and test the 200 EMA resistance level.
TF : 15min
Entry : $0.832
Target : $0.856
SL : $0.817
Today. I added to my experimental portfolio a coin - Lisk#LSK paired with #USDT on the Binance cryptocurrency exchange.
For me, this coin looks attractive for a long-term investment.
🛒Motives for buying#LSK
#Lisk ranks 63rd in the CoinMarketCap rating.
Good fundamental analysis is expected by the end of the year, including the halving on September 28.
The coin was not pumped!
The price is close to the resistance zone $1.6555-1.8727,
Support level is the $1.2840-1.0440.
The price projector points to a rise of $3.30.
I expect to grow from 130% to 180%.
🎯 Fibonacci 10$ experiment.