@verse · Post #108 · 20.07.2024 г., 12:58
Cycling alone Past Andrew Wyeth fields – No lid on the world! #haiku by MR
Hashtags
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
Пребарај: #haiku
@verse · Post #108 · 20.07.2024 г., 12:58
Cycling alone Past Andrew Wyeth fields – No lid on the world! #haiku by MR
Hashtags
@PensivePost · Post #5246 · 31.05.2021 г., 07:56
Relationship. On a lonely night, Two strangers bumped into eachother. And a relationship bloomed. #review#haiku
@QuietWorld · Post #6840 · 31.10.2019 г., 23:30
🔖Haiku 🌸“To sleep on our thoughts, Is better than to lose sleep over rash actions” #haiku#life#wisdom @quietworld🍃
@QuietWorld · Post #6766 · 22.10.2019 г., 13:01
🔖Haiku 🌸“When cherry blossoms scatter, no regrets.” .·. even when the cherry blossoms live for only a short period of time, they fall to their death with no regrets – because they offered beauty and loveliness around them. #haiku#life#kindness @quietworld🍃
@PensivePost · Post #5276 · 05.06.2021 г., 14:33
Mind had no more muse The poet in me, died and rot And my haiku cried. #review#haiku#nandini
@PensivePost · Post #5713 · 06.05.2022 г., 13:01
#review#iam#haiku Is this the demise of the unique journey?? If yes!!! Then what else is there in our stores?? Sounds meaningless!!!
@PensivePost · Post #5309 · 18.06.2021 г., 11:16
Haiku Sunshine after rain, Droplets on the spider web Glisten on and off. #review#haiku#Florence
@PensivePost · Post #5300 · 16.06.2021 г., 06:16
Haiku The storm raged outside Frightening the little blue birds And rain fell sideways. #haiku#review#Florence
@PensivePost · Post #5296 · 15.06.2021 г., 07:09
Haiku Look at the prim rose Rain-soaked, wind-kissed and enticed Emanating joy! #haiku#review#Florence
@PensivePost · Post #5275 · 05.06.2021 г., 13:52
Haiku Flowers in garden Basking in the petrichor Sway in balmy wind. #review#haiku#Florence
@PensivePost · Post #5247 · 31.05.2021 г., 17:15
Haiku Dark grey clouds gathered, A drop of rain on my nose Eruption of joy! #review#haiku#Florence
@PensivePost · Post #5236 · 29.05.2021 г., 13:33
HaikuHaiku A blooming red rose With raindrops like pearls Blushes like a bride. #review#haiku#Florence