{"id":476714,"date":"2026-04-20T18:03:45","date_gmt":"2026-04-20T18:03:45","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=476714"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=476714","title":{"rendered":"\u041a\u0430\u043a \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b Blue-Green \u0434\u0435\u043f\u043b\u043e\u0439 \u0441 \u043d\u0443\u043b\u0435\u0432\u044b\u043c \u0434\u0430\u0443\u043d\u0442\u0430\u0439\u043c\u043e\u043c \u043d\u0430 Docker Compose"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0432\u043d\u0435\u0434\u0440\u0438\u043b blue-green \u0434\u0435\u043f\u043b\u043e\u0439 \u0432 \u043f\u0440\u043e\u0434\u0435. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0430\u044f, \u043d\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043d\u0430 \u0443\u0440\u0430! \u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u043e\u0431\u0449\u0443, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043c\u043f\u043e\u0437 \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u043a\u0435 &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u043e\u043c\u0443-\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d.<\/p>\n<h2>\u0414\u043b\u044f \u0444\u043e\u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 (\u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432)<\/h2>\n<p>\u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 singleton \u043a\u043b\u0430\u0441\u0441 \u0441 \u0444\u043b\u0430\u0433\u043e\u043c is_accepting, \u0438 \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430 consumers. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043e\u043d\u0441\u044c\u044e\u043c\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0444\u043b\u0430\u0433: \u0435\u0441\u043b\u0438 True &#8212; \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443, \u0435\u0441\u043b\u0438 False &#8212; \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 rabbitmq \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 nack(requeue=true))<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b2f\/c00\/f01\/b2fc00f013d9cea5ec38a9ceb9cc55d2.png\" alt=\"\u0432\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0430 \u043d\u0430 \u042f\u041f python.\" title=\"\u0432\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0430 \u043d\u0430 \u042f\u041f python.\" width=\"694\" height=\"246\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b2f\/c00\/f01\/b2fc00f013d9cea5ec38a9ceb9cc55d2.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b2f\/c00\/f01\/b2fc00f013d9cea5ec38a9ceb9cc55d2.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0432\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0430 \u043d\u0430 \u042f\u041f python.<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/872\/1db\/fd7\/8721dbfd7797a62dbf43216040b0dbf5.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u0435\u0440\u0442\u043a\u0438. \u0415\u0441\u043b\u0438 is_accepting=False - \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u0435\u0440\u0442\u043a\u0438. \u0415\u0441\u043b\u0438 is_accepting=False - \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.\" width=\"694\" height=\"246\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/872\/1db\/fd7\/8721dbfd7797a62dbf43216040b0dbf5.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/872\/1db\/fd7\/8721dbfd7797a62dbf43216040b0dbf5.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u0435\u0440\u0442\u043a\u0438. \u0415\u0441\u043b\u0438 is_accepting=False &#8212; \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 sigterm \u0441\u0438\u0433\u043d\u0430\u043b, \u044d\u0442\u043e\u0442 singleton \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442 is_accepting \u0432 False. \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438(+5-10 \u0441\u0435\u043a\u0443\u043d\u0434), \u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c graceful timeout \u043d\u0430 5-10 \u0441\u0435\u043a\u0443\u043d\u0434 \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. <\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b92\/e5c\/5b4\/b92e5c5b4d298839769ad07d23b1e987.png\" alt=\"\u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f(is_accepting=False), \u0434\u0430\u0451\u043c \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0437\u0430\u0442\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Faststream \u043d\u0430 rabbitmq.\" title=\"\u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f(is_accepting=False), \u0434\u0430\u0451\u043c \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0437\u0430\u0442\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Faststream \u043d\u0430 rabbitmq.\" width=\"711\" height=\"629\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b92\/e5c\/5b4\/b92e5c5b4d298839769ad07d23b1e987.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b92\/e5c\/5b4\/b92e5c5b4d298839769ad07d23b1e987.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f(is_accepting=False), \u0434\u0430\u0451\u043c \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0437\u0430\u0442\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Faststream \u043d\u0430 rabbitmq.<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0445\u0440\u0443\u043f\u043a\u0438\u0439 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u043d\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u0435\u043d\u043e \u0441\u043c\u044b\u0441\u043b\u0430 &#8212; \u043c\u044b \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0443\u043f\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0432 graceful timeout \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043d\u0430\u0434\u0435\u0436\u043d\u0435\u0435 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a: \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0441\u043b\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f.<\/p>\n<blockquote>\n<p><strong>\u0422\u0430\u043a\u0436\u0435 \u0443\u0442\u043e\u0447\u043d\u044e<\/strong>, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0431\u044b\u043b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0432\u043e\u0440\u043a\u0435\u0440\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u0434\u0430\u0447. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Process Pool, \u0432\u0430\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f (\u0447\u0435\u0440\u0435\u0437 is_accepting) \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435! \u0418\u043d\u0430\u0447\u0435 \u043a\u043e\u043d\u0441\u0443\u043c\u0435\u0440\u044b \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445 \u0431\u0443\u0434\u0443\u0442 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u043b \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u043a\u043b\u044e\u0447\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0434\u0435\u043f\u043b\u043e\u0439, \u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435.<\/p>\n<\/blockquote>\n<p>\u0412 \u0434\u0435\u043f\u043b\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u043b\u043e\u0433\u0438\u043a\u0430 \u0442\u0430\u043a\u0430\u044f: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 (\u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0443\/\u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\/etc), \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c inactive \u0438\u043d\u0441\u0442\u0430\u043d\u0441. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0443 \u043d\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0431\u0430 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 \u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438. \u0414\u0430\u043b\u044c\u0448\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c sigterm \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443 &#8212; \u043e\u043d \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e (is_accepting=False), \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0434\u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u0445. <\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0434\u0435\u043f\u043b\u043e\u044f:<\/p>\n<pre><code class=\"bash\">set -eDEPLOY_PATH=\"$1\"COMPOSE=\"docker compose -f ${DEPLOY_PATH}\/docker-compose.prod.yml\"if docker ps --format '{{.Names}}' | grep -q \"^notifier-blue$\"; then  ACTIVE=\"blue\"  INACTIVE=\"green\"else  ACTIVE=\"green\"  INACTIVE=\"blue\"fiecho \"[notifier] active=${ACTIVE}, deploying to=${INACTIVE}\"$COMPOSE up -d notifier-${INACTIVE}$COMPOSE stop notifier-${ACTIVE}echo \"[notifier] done\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>P.S. \u0414\u043b\u044f \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u044b\u0445\u043a\u043e\u043d\u0441\u044c\u044e\u043c\u0435\u0440\u043e\u0432 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435\u00a0\u2014 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u00a0\u0434\u0435\u043b\u0430\u0442\u044c =) \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0435\u0439\u0437\u0438\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0441\u00a0requeue=True, \u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 RabbitMQ \u0441\u0430\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432\u00a0\u043e\u0447\u0435\u0440\u0435\u0434\u044c. \u041d\u043e\u00a0\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0441\u00a0\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0442.\u043a \u0432\u043e\u00a0\u0432\u0440\u0435\u043c\u044f \u0434\u0435\u043f\u043b\u043e\u044f \u043c\u044b \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u044b\u0442\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0421\u00a0\u043d\u0435\u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u044b\u043c\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0443\u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0439\u00a0\u2014 \u043f\u0440\u0438\u00a0\u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0435\u043a\u043e\u043d\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435(\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u043f\u0430\u0434\u0435\u043c \u043f\u0440\u0438\u00a0\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 id \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f). \u0410\u00a0\u043d\u0435\u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e.<\/p>\n<h2>\u0414\u043b\u044f \u0432\u0435\u0431 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/h2>\n<p>\u0412\u00a0\u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u0443\u00a0\u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c 2\u00a0\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u00a0\u2014 blue \u0438 green. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u0435\u043d \u0440\u0435\u0432\u0435\u0440\u0441\u2011\u043f\u0440\u043e\u043a\u0441\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 nginx.<\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 \u0434\u0435\u043f\u043b\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 if \u043b\u043e\u0433\u0438\u043a\u0443: \u0435\u0441\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u0435\u043d blue &#8212; Active = blue, Inactive = green, \u0432 \u043b\u044e\u0431\u043e\u043c \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 Active=green, Inactive = blue. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0435\/\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u043f\u043e\u0440\u0442\u0443\/etc. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c inactive \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 healthcheck.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c nginx \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441, \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430: echo \u201cserver ${HOST}${INACTIVE_PORT};\u201d &gt; \u201c$UPSTREAM_CONF\u201d \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u043c\u044f\u0433\u043a\u0438\u0439 \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u044b\u0439 reload(nginx -s reload). \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f, \u0440\u0430\u0432\u043d\u043e\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f http \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435(\u0441 \u0437\u0430\u043f\u0430\u0441\u043e\u043c). \u0417\u0430\u0442\u0435\u043c \u0441\u0442\u0430\u0440\u043e\u043c\u0443 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u043c sigterm \u0441\u0438\u0433\u043d\u0430\u043b.<\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0434\u0435\u043f\u043b\u043e\u044f:<\/p>\n<pre><code class=\"bash\">set -eIMAGE=\"$1\"DEPLOY_PATH=\"$2\"BLUE_PORT=${BLUE_PORT:-8002}GREEN_PORT=${GREEN_PORT:-8003}UPSTREAM_CONF=\"\/etc\/nginx\/snippets\/web-upstream.conf\"COMPOSE=\"docker compose -f ${DEPLOY_PATH}\/docker-compose.prod.yml\"if grep -q \"${BLUE_PORT}\" \"$UPSTREAM_CONF\"; then  ACTIVE=\"blue\"  INACTIVE=\"green\"  INACTIVE_PORT=$GREEN_PORTelse  ACTIVE=\"green\"  INACTIVE=\"blue\"  INACTIVE_PORT=$BLUE_PORTfiecho \"[blue-green] active=${ACTIVE}, deploying to=${INACTIVE} (port ${INACTIVE_PORT})\"$COMPOSE up -d web-${INACTIVE}echo \"[blue-green] waiting for health...\"for i in $(seq 1 30); do  if curl -sf \"http:\/\/127.0.0.1:${INACTIVE_PORT}\/v1\/health\" &gt; \/dev\/null 2&gt;&amp;1; then    echo \"[blue-green] healthy after ${i} attempts\"    break  fi  if [ \"$i\" -eq 30 ]; then    echo \"[blue-green] health check failed, rolling back\"    $COMPOSE stop web-${INACTIVE}    exit 1  fi  sleep 2doneecho \"server 127.0.0.1:${INACTIVE_PORT};\" &gt; \"$UPSTREAM_CONF\"nginx -t &amp;&amp; nginx -s reloadecho \"[blue-green] nginx switched to ${INACTIVE}\"sleep 5$COMPOSE stop web-${ACTIVE}echo \"[blue-green] stopped web-${ACTIVE}, deploy complete\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u0445<\/h2>\n<p>\u0412 blue green \u0434\u0435\u043f\u043b\u043e\u0435 \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u043e\u0432\u0430\u044f \u0438 \u0441\u0442\u0430\u0440\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u043b\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u043e\u0439 \u0431\u0434. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c backward compatible \u043f\u043e\u0434\u0445\u043e\u0434: \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0438\u043b\u0438 \u0446\u0435\u043b\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#8212; \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u0434\u0435 \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0435\u043f\u043b\u043e\u0439. \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0430\u0440\u044b\u0445 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u0435\u043f\u043b\u043e\u0439 \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435. \u0414\u0430, \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u044b &#8212; \u043d\u043e \u044d\u0442\u043e \u0442\u043e\u0433\u043e \u0441\u0442\u043e\u0438\u0442. <\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Docker Compose<\/h2>\n<p>\u0412\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043c\u043f\u043e\u0437 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"yaml\">services:  ...  web-blue:    image: ${CI_REGISTRY_IMAGE}\/web:${IMAGE_TAG:-latest}    container_name: web-blue    restart: always    env_file:      - .env.prod    ports:      - \"127.0.0.1:8002:8000\"    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy  web-green:    image: ${CI_REGISTRY_IMAGE}\/web:${IMAGE_TAG:-latest}    container_name: web-green    restart: always    env_file:      - .env.prod    ports:      - \"127.0.0.1:8003:8000\"    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy  worker-blue:    image: ${CI_REGISTRY_IMAGE}\/worker:${IMAGE_TAG:-latest}    container_name: worker-blue    restart: always    stop_grace_period: 200s    env_file:      - .env.prod    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy      redis:        condition: service_healthy  worker-green:    image: ${CI_REGISTRY_IMAGE}\/worker:${IMAGE_TAG:-latest}    container_name: worker-green    restart: always    stop_grace_period: 200s    env_file:      - .env.prod    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy      redis:        condition: service_healthy  notifier-blue:    image: ${CI_REGISTRY_IMAGE}\/notifier:${IMAGE_TAG:-latest}    container_name: notifier-blue    restart: always    stop_grace_period: 15s    env_file:      - .env.prod    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy      redis:        condition: service_healthy  notifier-green:    image: ${CI_REGISTRY_IMAGE}\/notifier:${IMAGE_TAG:-latest}    container_name: notifier-green    restart: always    stop_grace_period: 15s    env_file:      - .env.prod    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy      redis:        condition: service_healthy  ...<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u00a0\u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 blue\u2011green \u0434\u0435\u043f\u043b\u043e\u0439 \u0441\u00a0\u043d\u0443\u043b\u0435\u0432\u044b\u043c \u0434\u0430\u0443\u043d\u0442\u0430\u0439\u043c\u043e\u043c, \u0438 \u0432\u0441\u0451 \u044d\u0442\u043e \u043d\u0430\u00a0\u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043c\u043f\u043e\u0437.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0438\u0434\u0435\u0438, \u043a\u0430\u043a\u00a0\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u0435\u0435, \u0438\u043b\u0438\u00a0\u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u043f\u043e\u00a0\u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u043c \u043a\u0430\u043c\u043d\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043c\u043e\u0433 \u043d\u0435\u00a0\u0443\u0447\u0435\u0441\u0442\u044c\u00a0\u2014 \u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c!<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1025776\/\">https:\/\/habr.com\/ru\/articles\/1025776\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0432\u043d\u0435\u0434\u0440\u0438\u043b blue-green \u0434\u0435\u043f\u043b\u043e\u0439 \u0432 \u043f\u0440\u043e\u0434\u0435. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0430\u044f, \u043d\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043d\u0430 \u0443\u0440\u0430! \u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u043e\u0431\u0449\u0443, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043c\u043f\u043e\u0437 \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u043a\u0435 &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u043e\u043c\u0443-\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d.\u0414\u043b\u044f \u0444\u043e\u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 (\u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432)\u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 singleton \u043a\u043b\u0430\u0441\u0441 \u0441 \u0444\u043b\u0430\u0433\u043e\u043c is_accepting, \u0438 \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430 consumers. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043e\u043d\u0441\u044c\u044e\u043c\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0444\u043b\u0430\u0433: \u0435\u0441\u043b\u0438 True &#8212; \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443, \u0435\u0441\u043b\u0438 False &#8212; \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 rabbitmq \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 nack(requeue=true))\u0432\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0430 \u043d\u0430 \u042f\u041f python.\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u0435\u0440\u0442\u043a\u0438. \u0415\u0441\u043b\u0438 is_accepting=False &#8212; \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.\u041a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 sigterm \u0441\u0438\u0433\u043d\u0430\u043b, \u044d\u0442\u043e\u0442 singleton \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442 is_accepting \u0432 False. \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438(+5-10 \u0441\u0435\u043a\u0443\u043d\u0434), \u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c graceful timeout \u043d\u0430 5-10 \u0441\u0435\u043a\u0443\u043d\u0434 \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f(is_accepting=False), \u0434\u0430\u0451\u043c \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0437\u0430\u0442\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Faststream \u043d\u0430 rabbitmq.\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0445\u0440\u0443\u043f\u043a\u0438\u0439 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u043d\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u0435\u043d\u043e \u0441\u043c\u044b\u0441\u043b\u0430 &#8212; \u043c\u044b \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0443\u043f\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0432 graceful timeout \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043d\u0430\u0434\u0435\u0436\u043d\u0435\u0435 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.\u041f\u043e \u0441\u0443\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a: \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0441\u043b\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f.\u0422\u0430\u043a\u0436\u0435 \u0443\u0442\u043e\u0447\u043d\u044e, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0431\u044b\u043b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0432\u043e\u0440\u043a\u0435\u0440\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u0434\u0430\u0447. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Process Pool, \u0432\u0430\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f (\u0447\u0435\u0440\u0435\u0437 is_accepting) \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435! \u0418\u043d\u0430\u0447\u0435 \u043a\u043e\u043d\u0441\u0443\u043c\u0435\u0440\u044b \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445 \u0431\u0443\u0434\u0443\u0442 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u043b \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u043a\u043b\u044e\u0447\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0434\u0435\u043f\u043b\u043e\u0439, \u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435.\u0412 \u0434\u0435\u043f\u043b\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u043b\u043e\u0433\u0438\u043a\u0430 \u0442\u0430\u043a\u0430\u044f: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 (\u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0443\/\u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\/etc), \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c inactive \u0438\u043d\u0441\u0442\u0430\u043d\u0441. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0443 \u043d\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0431\u0430 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 \u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438. \u0414\u0430\u043b\u044c\u0448\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c sigterm \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443 &#8212; \u043e\u043d \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e (is_accepting=False), \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0434\u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u0445. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0434\u0435\u043f\u043b\u043e\u044f:set -eDEPLOY_PATH=&#187;$1&#8243;COMPOSE=&#187;docker compose -f ${DEPLOY_PATH}\/docker-compose.prod.yml&#187;if docker ps &#8212;format &#8216;{{.Names}}&#8217; | grep -q &#171;^notifier-blue$&#187;; then  ACTIVE=&#187;blue&#187;  INACTIVE=&#187;green&#187;else  ACTIVE=&#187;green&#187;  INACTIVE=&#187;blue&#187;fiecho &#171;[notifier] active=${ACTIVE}, deploying to=${INACTIVE}&#187;$COMPOSE up -d notifier-${INACTIVE}$COMPOSE stop notifier-${ACTIVE}echo &#171;[notifier] done&#187;P.S. \u0414\u043b\u044f \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u044b\u0445\u043a\u043e\u043d\u0441\u044c\u044e\u043c\u0435\u0440\u043e\u0432 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435\u00a0\u2014 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u00a0\u0434\u0435\u043b\u0430\u0442\u044c =) \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0435\u0439\u0437\u0438\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0441\u00a0requeue=True, \u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 RabbitMQ \u0441\u0430\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432\u00a0\u043e\u0447\u0435\u0440\u0435\u0434\u044c. \u041d\u043e\u00a0\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0441\u00a0\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0442.\u043a \u0432\u043e\u00a0\u0432\u0440\u0435\u043c\u044f \u0434\u0435\u043f\u043b\u043e\u044f \u043c\u044b \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u044b\u0442\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0421\u00a0\u043d\u0435\u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u044b\u043c\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0443\u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0439\u00a0\u2014 \u043f\u0440\u0438\u00a0\u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0435\u043a\u043e\u043d\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435(\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u043f\u0430\u0434\u0435\u043c \u043f\u0440\u0438\u00a0\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 id \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f). \u0410\u00a0\u043d\u0435\u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e.\u0414\u043b\u044f \u0432\u0435\u0431 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432\u0412\u00a0\u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u0443\u00a0\u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c 2\u00a0\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u00a0\u2014 blue \u0438 green. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u0435\u043d \u0440\u0435\u0432\u0435\u0440\u0441\u2011\u043f\u0440\u043e\u043a\u0441\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 nginx.\u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 \u0434\u0435\u043f\u043b\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 if \u043b\u043e\u0433\u0438\u043a\u0443: \u0435\u0441\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u0435\u043d blue &#8212; Active = blue, Inactive = green, \u0432 \u043b\u044e\u0431\u043e\u043c \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 Active=green, Inactive = blue. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0435\/\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u043f\u043e\u0440\u0442\u0443\/etc. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c inactive \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 healthcheck.\u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c nginx \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441, \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430: echo \u201cserver ${HOST}${INACTIVE_PORT};\u201d &gt; \u201c$UPSTREAM_CONF\u201d \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u043c\u044f\u0433\u043a\u0438\u0439 \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u044b\u0439 reload(nginx -s reload). \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f, \u0440\u0430\u0432\u043d\u043e\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f http \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435(\u0441 \u0437\u0430\u043f\u0430\u0441\u043e\u043c). \u0417\u0430\u0442\u0435\u043c \u0441\u0442\u0430\u0440\u043e\u043c\u0443 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u043c sigterm \u0441\u0438\u0433\u043d\u0430\u043b.\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0434\u0435\u043f\u043b\u043e\u044f:set -eIMAGE=&#187;$1&#8243;DEPLOY_PATH=&#187;$2&#8243;BLUE_PORT=${BLUE_PORT:-8002}GREEN_PORT=${GREEN_PORT:-8003}UPSTREAM_CONF=&#187;\/etc\/nginx\/snippets\/web-upstream.conf&#187;COMPOSE=&#187;docker compose -f ${DEPLOY_PATH}\/docker-compose.prod.yml&#187;if grep -q &#171;${BLUE_PORT}&#187; &#171;$UPSTREAM_CONF&#187;; then  ACTIVE=&#187;blue&#187;  INACTIVE=&#187;green&#187;  INACTIVE_PORT=$GREEN_PORTelse  ACTIVE=&#187;green&#187;  INACTIVE=&#187;blue&#187;  INACTIVE_PORT=$BLUE_PORTfiecho &#171;[blue-green] active=${ACTIVE}, deploying to=${INACTIVE} (port ${INACTIVE_PORT})&#187;$COMPOSE up -d web-${INACTIVE}echo &#171;[blue-green] waiting for health&#8230;&#187;for i in $(seq 1 30); do  if curl -sf &#171;http:\/\/127.0.0.1:${INACTIVE_PORT}\/v1\/health&#187; &gt; \/dev\/null 2&gt;&amp;1; then    echo &#171;[blue-green] healthy after ${i} attempts&#187;    break  fi  if [ &#171;$i&#187; -eq 30 ]; then    echo &#171;[blue-green] health check failed, rolling back&#187;    $COMPOSE stop web-${INACTIVE}    exit 1  fi  sleep 2doneecho &#171;server 127.0.0.1:${INACTIVE_PORT};&#187; &gt; &#171;$UPSTREAM_CONF&#187;nginx -t &amp;&amp; nginx -s reloadecho &#171;[blue-green] nginx switched to ${INACTIVE}&#187;sleep 5$COMPOSE stop web-${ACTIVE}echo &#171;[blue-green] stopped web-${ACTIVE}, deploy complete&#187;\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u0445\u0412 blue green \u0434\u0435\u043f\u043b\u043e\u0435 \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u043e\u0432\u0430\u044f \u0438 \u0441\u0442\u0430\u0440\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u043b\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u043e\u0439 \u0431\u0434. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c backward compatible \u043f\u043e\u0434\u0445\u043e\u0434: \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0438\u043b\u0438 \u0446\u0435\u043b\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#8212; \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u0434\u0435 \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0435\u043f\u043b\u043e\u0439. \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0430\u0440\u044b\u0445 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u0435\u043f\u043b\u043e\u0439 \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435. \u0414\u0430, \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u044b &#8212; \u043d\u043e \u044d\u0442\u043e \u0442\u043e\u0433\u043e \u0441\u0442\u043e\u0438\u0442. \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Docker Compose\u0412\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043c\u043f\u043e\u0437 \u0444\u0430\u0439\u043b\u0430:services:  &#8230;  web-blue:    image: ${CI_REGISTRY_IMAGE}\/web:${IMAGE_TAG:-latest}    container_name: web-blue    restart: always    env_file:      &#8212; .env.prod    ports:      &#8212; &#171;127.0.0.1:8002:8000&#187;    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy  web-green:    image: ${CI_REGISTRY_IMAGE}\/web:${IMAGE_TAG:-latest}    container_name: web-green    restart: always    env_file:      &#8212; .env.prod    ports:      &#8212; &#171;127.0.0.1:8003:8000&#187;    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy  worker-blue:    image: ${CI_REGISTRY_IMAGE}\/worker:${IMAGE_TAG:-latest}    container_name: worker-blue    restart: always    stop_grace_period: 200s    env_file:      &#8212; .env.prod    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy      redis:        condition: service_healthy  worker-green:    image: ${CI_REGISTRY_IMAGE}\/worker:${IMAGE_TAG:-latest}    container_name: worker-green    restart: always    stop_grace_period: 200s    env_file:      &#8212; .env.prod    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy      redis:        condition: service_healthy  notifier-blue:    image: ${CI_REGISTRY_IMAGE}\/notifier:${IMAGE_TAG:-latest}    container_name: notifier-blue    restart: always    stop_grace_period: 15s    env_file:      &#8212; .env.prod    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy      redis:        condition: service_healthy  notifier-green:    image: ${CI_REGISTRY_IMAGE}\/notifier:${IMAGE_TAG:-latest}    container_name: notifier-green    restart: always    stop_grace_period: 15s    env_file:      &#8212; .env.prod    depends_on:      migrations:        condition: service_completed_successfully      postgres:        condition: service_healthy      rabbitmq:        condition: service_healthy      redis:        condition: service_healthy  &#8230;\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u0412\u00a0\u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 blue\u2011green \u0434\u0435\u043f\u043b\u043e\u0439 \u0441\u00a0\u043d\u0443\u043b\u0435\u0432\u044b\u043c \u0434\u0430\u0443\u043d\u0442\u0430\u0439\u043c\u043e\u043c, \u0438 \u0432\u0441\u0451 \u044d\u0442\u043e \u043d\u0430\u00a0\u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043c\u043f\u043e\u0437.\u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0438\u0434\u0435\u0438, \u043a\u0430\u043a\u00a0\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u0435\u0435, \u0438\u043b\u0438\u00a0\u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u043f\u043e\u00a0\u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u043c \u043a\u0430\u043c\u043d\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043c\u043e\u0433 \u043d\u0435\u00a0\u0443\u0447\u0435\u0441\u0442\u044c\u00a0\u2014 \u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c!\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 https:\/\/habr.com\/ru\/articles\/1025776\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-476714","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/476714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=476714"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/476714\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=476714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=476714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=476714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}