TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #411 · 9 фев.

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

Резултати

Пронајдени 4 слични објави

Пребарај: #gamelaunch

当前筛选 #gamelaunch清除筛选
SingSing Announcement

@singsingchannel · Post #1130 · 24.12.2024 г., 01:25

🌟Mystic Garden is Officially Open!🌟 🎉 The wait is over—step into the magic now! 🔸AURA Launchpool Stakers: Your AURA rewards are ready! 🔸Beta Testers: Enjoy 2x AURA on your deposits and beta test reward as a special thank-you! 🔸Everyone: It’s time to explore, grow, and thrive in Mystic Garden! Let the adventure begin! 🌱✨ Play Now: https://t.me/mystic_garden_bot/app #MysticGarden#GameLaunch#AURARewards

SingSing Announcement

@singsingchannel · Post #1125 · 22.12.2024 г., 02:05

🎄Christmas is Coming... and so is Mystic Garden!🌟 This holiday season, unwrap the magic with the official launch of Mystic Garden on Dec 24! 🌱✨ Get ready to plant, harvest, and earn as the garden blooms with festive cheer. 🎁 Don’t miss it! #MysticGarden#GameLaunch#PlayToEarn#Web3Gaming

SingSing Announcement

@singsingchannel · Post #814 · 21.09.2024 г., 05:07

🚀 The long-awaited SingSing Tycoon Game is about to launch! 🚀 ⏰Save the schedule:14:00 UTC Today - Sep 21⏰ In just a few hours, you’ll officially step into the world of SingSing Tycoon! Get ready to build your own karaoke chain, upgrade booths, expand your shop, and grow your ultimate entertainment empire! 🎤💰 Exciting adventures await. Be prepared—this is going to be epic! 💥 #SingSingTycoon#GameLaunch#KaraokeEmpire#PlayToEarn#SingSing Announcement | Chat | X (Twitter) | Website | Game

SingSing Announcement

@singsingchannel · Post #816 · 21.09.2024 г., 16:57

🚀SingSing Tycoon Game is Officially LIVE!🚀 The wait is over, SingSing Tycoon Game is Live Now 👉https://t.me/SingSing_TG_bot/app?startapp=_ktvgame Build your empire, compete with friends, and rise to the top! 💼🏆 Note: Lucky Box Owners and Kara Box Owners can now unbox in the Tycoon Game! 🎁✨ Don’t miss out—start your journey today! 🎮 #SingSingTycoon#GameLaunch#PlayNow#BuildYourEmpire 🎤Announcement | Chat | X (Twitter) | Website | Game