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
#Back Stronger And Better.🦾
Getting Back On Track After An Unsuccessful Losing Streak
Did you lose a huge amount of money in Forex trading and want to desperately win your trading losses back? Don't worry! This has happened to many traders before and there are people who have got back on track. Losing a huge fortune may appear to be an indication of the end of your Forex trading career but it doesn't have to be. Treat your previous losing streak as the greatest lesson that you have had and start all over again. The only thing you need to make sure is not to repeat the same mistakes that you have committed before.
Forex trading is a career that requires a good discipline, patience, emotional stability and hard work. When you loose a huge money for the first time, you might have done the trading blunders that new traders often make. If you are aware of those mistakes and ensure not to do them again, then no one can stop you from succeeding in Forex. But always keep in mind that success doesn't come overnight. It takes years and you have to accept this reality.
Below are few guided steps to pull your string back;
• Take a break to ensure that your mind is free from any regrets or other negative emotions, this will make you slowly unburden yourself from the past and give you the necessary courage and confidence to start trading again.
• Review the mistakes you did the last time, including lack of proper training, poor risk management, and poor emotional management. Make a list of beginner's mistakes in Forex and clearly understand how those mistakes can ruin a trading account... Check most of our previous articles for better understanding on some beginners mistakes so you can be properly guided.
• Refresh your knowledge in Forex, do demo trading and back testing for a few days and start with the small account first. Make sure that the account size gives you enough room to take risks, as you must never risk more than 2% of your capital. Once you start winning some trades, you will get a strong confidence.
FxSignals_Gold Team.