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
To clarify, in the post about the Bulcoin Referral Program, by "invitation to the channel" we meant subscription to the channel. To receive rewards, those who wrote your username in the comments must be subscribed
#referrals
FAQ | BUY
Now is the best time to enter BLC Market.
Early stage project:
- actively forming structure
- interfaces are being published
- new mechanics are opening up
If you're already here - you're getting in ahead of most.
Scaling will follow next.
#community#referrals
FAQ | BUY
👥 The system of inviting friends to CITY Holder! 🏠🐹
With the invitation system you get in-game income not only for inviting friends, but also for their further development! The better your buddy's results, the higher your income. Combine strategies and show incredible results! #CITYHolder#Referrals
https://t.me/cityholder🆕👈
°°°°°°
Launching the BulCoin Referral Program
We are starting a referral program for the early BulCoin community.
Now every participant can invite friends to the project and receive additional bonuses.
How it works:
Invite your friends to the BulCoin channel
Ask them to mention your username in the comments to this post
Bonuses BLC are credited for invitations
Rewards:
• 3 invited — You join the private Pioneers chat
• 10 invited — Bonus of 500,000 BLC
• 25 invited — 3mln BLC + Participation in the BulCoin operational staff
We will regularly publish the leaderboard — participants who have invited the most people.
The best participants can receive additional rewards and a special status in the community.
This is just the beginning of the formation of the BulCoin Early Community
Invite your friends and help build the BulCoin community
#Pioneers#Referrals
FAQ | BUY
Invitation mechanics in BLC Market
There will be a separate section in the app through which you can invite new users.
This will allow:
— community to grow faster
— build connections between members
— increase activity within the platform
We will show the interface in the upcoming updates.
#profile#community#referrals
FAQ | BUY
🎉 Invite Reward Boost! 🎉
Invite friends to join SingSing and earn 20 $KARA FREE for each successful invite (up from 10 $KARA)! 🔥
👥 The more, the merrier – stack up your $KARA effortlessly!
💸 Start inviting now and claim your rewards!
#SingSing#KARA#Invite#Referrals
🎤Announcement | Chat | X (Twitter) | Website | Game