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
✨ WEEKLY LEADERBOARD UPDATE: WEEK 3 FEBRUARY CHAMPIONS! 🔼
The battle was intense, but these Gumart residents dominated the game! 🚀 Let’s celebrate our top performers who secured their spots at the top.
🏆 Top Achievers – Week 3 February:
🥇1st Place:@rich***00 - 50 USDT
🥈2nd Place:@Bury***ke - 20 USDT
🥉 3rd Place: @aoi_***ng - 20 USDT
🎮 Top 10 Most Engaged in Gumart Chat:
Each winner receives 10 USDT for keeping the conversation alive! (English messages only)
🏅 Winners, check your bot notifications and claim your rewards! The next leaderboard race is ON – will you be the next champion? ⚔️💰
#Minigame
Join the KardiaChain ♥️ Mass Adoption Mini Games for a chance to win a part of 200$!
UTC 12:00 17th Oct - 12:00 19th Oct
🎮Game Mechanics below 👇🏻
Mini Game 🎮 1:
1. Go to 🌐https://forms.gle/de2UYK7onyduqmVn8
2. Submit the correct answer the fastest to win 25$
3. Next 5 submissions with the correct answers also gets 10$ Each
Mini Game 🎮 2:
1. Go to KardiaChain's♥️ TelegramCommunity
2. Submit you proposal idea on the thread here about the future of Web 3.0 and what KardiaChain's next steps should be on the path of achieving mass adoption.
3. Receive the most like/reaction and get 25$
Next 10 submissions with the most likes/reactions also wins 10$ each
#Giveaway#MiniGame#Partnership#Web3
KardiaChain Socials :
🌐Website | 🐦Twitter |🌐Community | 🌐Channel
☑️Disclaimer: Please do your own research before joining to any project.
Do you want to learn more about #KAIDEX x Ameta? 📣
Join the KAHOOT Mini Game for a chance to Learn & Earn a reward pool of 100$ in $APLUS!
Quiz starts on 01:00 PM UTC, 3rd Oct 2022 onJoin Now
Kahoot link soon 👀
TOP 5 winners will receive 20$ of APLUS each 💰🤑
#MiniGame#Giveaway#Airdrop $KDX
Disclaimer: Please do your own research before joining to any airdrops project, also airdrop is 100% free. Don't send any fee or penny for receiving airdrop tokens. Just join airdrop for free!
✅✅✅✅#Official KuCoin and TON Present Frog Trader #Minigame on Telegram! 🤩 Brought to you by KuCoin, a leading global crypto exchange trusted by one in four crypto holders worldwide! #Get Upto 2 lack coins
🐸 Welcome reward of 10K Frog Coins! join fast guys :- https://t.me/xkucoinbot/kucoinminiapp?startapp=cm91dGU9JTJGdGFwLWdhbWUlM0ZpbnZpdGVyVXNlcklkJTNEMTA0ODM5NjMwMSUyNnJjb2RlJTNEUUJBWkdRQUs=
➖ Click on bot
➖ Check your telegram age
➖ Link your kucoin exchange account
➖ Connect telegram wallet only
➖ Premium users will get 50k
#Note :- Don't skip #early users will get more benefits join fast before end
📈
🐹Solution for the new mini-game in
Hamster Kombat
👉https:://t.me/hamster_kombat
📣Stay updated! Subscribe to our channel:
⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️
#hamsterkombat#hamster#kombat#key#btc#combo#hamsterkey#minigame#game#clicker#taptap#memecoin