[{"data":1,"prerenderedAt":1961},["ShallowReactive",2],{"navigation_docs":3,"-backend-development-graceful-shutdown":377,"-backend-development-graceful-shutdown-surround":1956},[4,39,114,144,184,244,293,362],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":6},"Getting Started",false,"\u002Fgetting-started","1.getting-started",[10,15,20,25,30,35],{"title":11,"path":12,"stem":13,"icon":14},"Learning Path","\u002Fgetting-started\u002Flearning-path","1.getting-started\u002F1.learning-path","i-lucide-map",{"title":16,"path":17,"stem":18,"icon":19},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F2.introduction","i-lucide-house",{"title":21,"path":22,"stem":23,"icon":24},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F3.installation","i-lucide-download",{"title":26,"path":27,"stem":28,"icon":29},"Your First Program","\u002Fgetting-started\u002Ffirst-program","1.getting-started\u002F4.first-program","i-lucide-play",{"title":31,"path":32,"stem":33,"icon":34},"Modules and Dependencies","\u002Fgetting-started\u002Fmodules-and-dependencies","1.getting-started\u002F5.modules-and-dependencies","i-lucide-package-open",{"title":36,"path":37,"stem":38,"icon":34},"Advanced Modules","\u002Fgetting-started\u002Fadvanced-modules","1.getting-started\u002F6.advanced-modules",{"title":40,"path":41,"stem":42,"children":43,"page":6},"Fundamentals","\u002Ffundamentals","2.fundamentals",[44,49,54,59,64,69,74,79,84,89,94,99,104,109],{"title":45,"path":46,"stem":47,"icon":48},"Program Structure","\u002Ffundamentals\u002Fprogram-structure","2.fundamentals\u002F1.program-structure","i-lucide-workflow",{"title":50,"path":51,"stem":52,"icon":53},"Structs and Methods","\u002Ffundamentals\u002Fstructs-and-methods","2.fundamentals\u002F10.structs-and-methods","i-lucide-box",{"title":55,"path":56,"stem":57,"icon":58},"Interfaces","\u002Ffundamentals\u002Finterfaces","2.fundamentals\u002F11.interfaces","i-lucide-plug",{"title":60,"path":61,"stem":62,"icon":63},"Error Handling","\u002Ffundamentals\u002Ferrors","2.fundamentals\u002F12.errors","i-lucide-triangle-alert",{"title":65,"path":66,"stem":67,"icon":68},"Defined Types and Type Aliases","\u002Ffundamentals\u002Fdefined-types","2.fundamentals\u002F13.defined-types","i-lucide-tags",{"title":70,"path":71,"stem":72,"icon":73},"Generics","\u002Ffundamentals\u002Fgenerics","2.fundamentals\u002F14.generics","i-lucide-blocks",{"title":75,"path":76,"stem":77,"icon":78},"Project Structure","\u002Ffundamentals\u002Fproject-structure","2.fundamentals\u002F2.project-structure","i-lucide-folder-tree",{"title":80,"path":81,"stem":82,"icon":83},"Project Layout","\u002Ffundamentals\u002Fproject-layout","2.fundamentals\u002F3.project-layout","i-lucide-layout",{"title":85,"path":86,"stem":87,"icon":88},"Variables and Data Types","\u002Ffundamentals\u002Fvariables-and-types","2.fundamentals\u002F4.variables-and-types","i-lucide-variable",{"title":90,"path":91,"stem":92,"icon":93},"Functions","\u002Ffundamentals\u002Ffunctions","2.fundamentals\u002F5.functions","i-lucide-braces",{"title":95,"path":96,"stem":97,"icon":98},"Control Statements","\u002Ffundamentals\u002Fcontrol-statements","2.fundamentals\u002F6.control-statements","i-lucide-git-branch",{"title":100,"path":101,"stem":102,"icon":103},"Pointers","\u002Ffundamentals\u002Fpointers","2.fundamentals\u002F7.pointers","i-lucide-mouse-pointer-2",{"title":105,"path":106,"stem":107,"icon":108},"Arrays and Slices","\u002Ffundamentals\u002Farrays-and-slices","2.fundamentals\u002F8.arrays-and-slices","i-lucide-list",{"title":110,"path":111,"stem":112,"icon":113},"Maps","\u002Ffundamentals\u002Fmaps","2.fundamentals\u002F9.maps","i-lucide-table-properties",{"title":115,"path":116,"stem":117,"children":118,"page":6},"Concurrency","\u002Fconcurrency","3.concurrency",[119,124,129,134,139],{"title":120,"path":121,"stem":122,"icon":123},"Concurrency Model","\u002Fconcurrency\u002Fconcurrency-model","3.concurrency\u002F1.concurrency-model","i-lucide-network",{"title":125,"path":126,"stem":127,"icon":128},"Goroutines","\u002Fconcurrency\u002Fgoroutines","3.concurrency\u002F2.goroutines","i-lucide-git-fork",{"title":130,"path":131,"stem":132,"icon":133},"Channels","\u002Fconcurrency\u002Fchannels","3.concurrency\u002F3.channels","i-lucide-arrow-left-right",{"title":135,"path":136,"stem":137,"icon":138},"Select and Cancellation","\u002Fconcurrency\u002Fselect-and-cancellation","3.concurrency\u002F4.select-and-cancellation","i-lucide-circle-stop",{"title":140,"path":141,"stem":142,"icon":143},"Synchronization","\u002Fconcurrency\u002Fsynchronization","3.concurrency\u002F5.synchronization","i-lucide-lock-keyhole",{"title":145,"path":146,"stem":147,"children":148,"page":6},"Standard Library","\u002Fstandard-library","4.standard-library",[149,154,159,164,169,174,179],{"title":150,"path":151,"stem":152,"icon":153},"Standard Library Overview","\u002Fstandard-library\u002Foverview","4.standard-library\u002F1.overview","i-lucide-library",{"title":155,"path":156,"stem":157,"icon":158},"Text and Formatting","\u002Fstandard-library\u002Ftext-and-formatting","4.standard-library\u002F2.text-and-formatting","i-lucide-text",{"title":160,"path":161,"stem":162,"icon":163},"Files and JSON","\u002Fstandard-library\u002Ffiles-and-json","4.standard-library\u002F3.files-and-json","i-lucide-file-json",{"title":165,"path":166,"stem":167,"icon":168},"HTTP Clients and Servers","\u002Fstandard-library\u002Fhttp","4.standard-library\u002F4.http","i-lucide-server",{"title":170,"path":171,"stem":172,"icon":173},"Testing","\u002Fstandard-library\u002Ftesting","4.standard-library\u002F5.testing","i-lucide-flask-conical",{"title":175,"path":176,"stem":177,"icon":178},"Command-Line Tools and Configuration","\u002Fstandard-library\u002Fcommand-line-and-configuration","4.standard-library\u002F6.command-line-and-configuration","i-lucide-terminal-square",{"title":180,"path":181,"stem":182,"icon":183},"Structured Logging","\u002Fstandard-library\u002Fstructured-logging","4.standard-library\u002F7.structured-logging","i-lucide-scroll-text",{"title":185,"path":186,"stem":187,"children":188,"page":6},"Backend Development","\u002Fbackend-development","5.backend-development",[189,194,199,204,209,214,219,224,229,234,239],{"title":190,"path":191,"stem":192,"icon":193},"Backend Roadmap","\u002Fbackend-development\u002Fbackend-roadmap","5.backend-development\u002F1.backend-roadmap","i-lucide-route",{"title":195,"path":196,"stem":197,"icon":198},"Graceful Shutdown","\u002Fbackend-development\u002Fgraceful-shutdown","5.backend-development\u002F10.graceful-shutdown","i-lucide-power",{"title":200,"path":201,"stem":202,"icon":203},"Production Checklist","\u002Fbackend-development\u002Fproduction-checklist","5.backend-development\u002F11.production-checklist","i-lucide-clipboard-check",{"title":205,"path":206,"stem":207,"icon":208},"HTTP API Design","\u002Fbackend-development\u002Fhttp-api-design","5.backend-development\u002F2.http-api-design","i-lucide-waypoints",{"title":210,"path":211,"stem":212,"icon":213},"Middleware","\u002Fbackend-development\u002Fmiddleware","5.backend-development\u002F3.middleware","i-lucide-layers-3",{"title":215,"path":216,"stem":217,"icon":218},"Validation","\u002Fbackend-development\u002Fvalidation","5.backend-development\u002F4.validation","i-lucide-list-checks",{"title":220,"path":221,"stem":222,"icon":223},"Application Wiring","\u002Fbackend-development\u002Fapplication-wiring","5.backend-development\u002F5.application-wiring","i-lucide-cable",{"title":225,"path":226,"stem":227,"icon":228},"Observability","\u002Fbackend-development\u002Fobservability","5.backend-development\u002F6.observability","i-lucide-activity",{"title":230,"path":231,"stem":232,"icon":233},"Database SQL","\u002Fbackend-development\u002Fdatabase-sql","5.backend-development\u002F7.database-sql","i-lucide-database",{"title":235,"path":236,"stem":237,"icon":238},"Transactions","\u002Fbackend-development\u002Ftransactions","5.backend-development\u002F8.transactions","i-lucide-repeat-2",{"title":240,"path":241,"stem":242,"icon":243},"Authentication and Authorization","\u002Fbackend-development\u002Fauthentication","5.backend-development\u002F9.authentication","i-lucide-shield-check",{"title":245,"path":246,"stem":247,"children":248,"page":6},"Advanced Go","\u002Fadvanced-go","6.advanced-go",[249,254,259,264,269,274,278,283,288],{"title":250,"path":251,"stem":252,"icon":253},"Advanced Go Roadmap","\u002Fadvanced-go\u002Fadvanced-roadmap","6.advanced-go\u002F1.advanced-roadmap","i-lucide-brain-circuit",{"title":255,"path":256,"stem":257,"icon":258},"Reflection","\u002Fadvanced-go\u002Freflection","6.advanced-go\u002F2.reflection","i-lucide-scan-search",{"title":260,"path":261,"stem":262,"icon":263},"Memory and Garbage Collection","\u002Fadvanced-go\u002Fmemory-and-garbage-collection","6.advanced-go\u002F3.memory-and-garbage-collection","i-lucide-memory-stick",{"title":265,"path":266,"stem":267,"icon":268},"Benchmarking and Profiling","\u002Fadvanced-go\u002Fbenchmarking-and-profiling","6.advanced-go\u002F4.benchmarking-and-profiling","i-lucide-gauge",{"title":270,"path":271,"stem":272,"icon":273},"Advanced Testing and Fuzzing","\u002Fadvanced-go\u002Fadvanced-testing-and-fuzzing","6.advanced-go\u002F5.advanced-testing-and-fuzzing","i-lucide-microscope",{"title":275,"path":276,"stem":277,"icon":48},"Advanced Concurrency","\u002Fadvanced-go\u002Fadvanced-concurrency","6.advanced-go\u002F6.advanced-concurrency",{"title":279,"path":280,"stem":281,"icon":282},"Unsafe and C Boundaries","\u002Fadvanced-go\u002Funsafe-and-cgo","6.advanced-go\u002F7.unsafe-and-cgo","i-lucide-radiation",{"title":284,"path":285,"stem":286,"icon":287},"Package and API Design","\u002Fadvanced-go\u002Fpackage-and-api-design","6.advanced-go\u002F8.package-and-api-design","i-lucide-boxes",{"title":289,"path":290,"stem":291,"icon":292},"Distributed Reliability","\u002Fadvanced-go\u002Fdistributed-reliability","6.advanced-go\u002F9.distributed-reliability","i-lucide-cloud-cog",{"title":294,"path":295,"stem":296,"children":297,"page":6},"Projects","\u002Fprojects","7.projects",[298,316,332,347],{"title":299,"path":300,"stem":301,"children":302,"icon":305},"CLI Task Manager","\u002Fprojects\u002Fcli-task-manager","7.projects\u002F1.cli-task-manager\u002Findex",[303,306,311],{"title":304,"path":300,"stem":301,"icon":305},"Project — CLI Task Manager","i-lucide-list-todo",{"title":307,"path":308,"stem":309,"icon":310},"CLI — Domain and Storage","\u002Fprojects\u002Fcli-task-manager\u002Fdomain-and-storage","7.projects\u002F1.cli-task-manager\u002F1.domain-and-storage","i-lucide-save",{"title":312,"path":313,"stem":314,"icon":315},"CLI — Commands and Tests","\u002Fprojects\u002Fcli-task-manager\u002Fcommands-and-tests","7.projects\u002F1.cli-task-manager\u002F2.commands-and-tests","i-lucide-terminal",{"title":317,"path":318,"stem":319,"children":320,"icon":323},"Concurrent URL Checker","\u002Fprojects\u002Fconcurrent-url-checker","7.projects\u002F2.concurrent-url-checker\u002Findex",[321,324,328],{"title":322,"path":318,"stem":319,"icon":323},"Project — Concurrent URL Checker","i-lucide-radar",{"title":325,"path":326,"stem":327,"icon":128},"URL Checker — Worker Pipeline","\u002Fprojects\u002Fconcurrent-url-checker\u002Fworker-pipeline","7.projects\u002F2.concurrent-url-checker\u002F1.worker-pipeline",{"title":329,"path":330,"stem":331,"icon":173},"URL Checker — Cancellation and Tests","\u002Fprojects\u002Fconcurrent-url-checker\u002Fcancellation-and-tests","7.projects\u002F2.concurrent-url-checker\u002F2.cancellation-and-tests",{"title":333,"path":334,"stem":335,"children":336},"File-backed API","\u002Fprojects\u002Ffile-backed-api","7.projects\u002F3.file-backed-api\u002Findex",[337,339,343],{"title":338,"path":334,"stem":335},"File-backed notes API",{"title":340,"path":341,"stem":342},"File store and concurrency","\u002Fprojects\u002Ffile-backed-api\u002Ffile-store-and-concurrency","7.projects\u002F3.file-backed-api\u002F1.file-store-and-concurrency",{"title":344,"path":345,"stem":346},"HTTP layer and tests","\u002Fprojects\u002Ffile-backed-api\u002Fhttp-and-tests","7.projects\u002F3.file-backed-api\u002F2.http-and-tests",{"title":348,"path":349,"stem":350,"children":351},"Production REST API","\u002Fprojects\u002Fproduction-rest-api","7.projects\u002F4.production-rest-api\u002Findex",[352,354,358],{"title":353,"path":349,"stem":350},"Production REST API capstone",{"title":355,"path":356,"stem":357},"Persistence and authentication","\u002Fprojects\u002Fproduction-rest-api\u002Fpersistence-and-auth","7.projects\u002F4.production-rest-api\u002F1.persistence-and-auth",{"title":359,"path":360,"stem":361},"Operations and release","\u002Fprojects\u002Fproduction-rest-api\u002Foperations-and-release","7.projects\u002F4.production-rest-api\u002F2.operations-and-release",{"title":363,"path":364,"stem":365,"children":366,"page":6},"Meta","\u002Fmeta","99.meta",[367,372],{"title":368,"path":369,"stem":370,"icon":371},"About","\u002Fmeta\u002Fabout","99.meta\u002F1.about","i-lucide-info",{"title":373,"path":374,"stem":375,"icon":376},"Acknowledgements","\u002Fmeta\u002Facknowledgements","99.meta\u002F2.acknowledgements","i-lucide-heart-handshake",{"id":378,"title":195,"body":379,"description":1948,"extension":1949,"links":1950,"meta":1951,"navigation":1952,"path":196,"seo":1953,"stem":197,"__hash__":1955},"docs\u002F5.backend-development\u002F10.graceful-shutdown.md",{"type":380,"value":381,"toc":1935},"minimark",[382,388,393,397,416,420,423,434,437,441,656,661,665,1052,1057,1060,1064,1067,1082,1085,1089,1371,1378,1382,1385,1408,1415,1419,1422,1425,1429,1476,1480,1483,1904,1908,1925,1928,1931],[383,384],"learning-lesson-meta",{"level":385,"prerequisites":386,"time":387},"Advanced","HTTP servers, context, goroutines, WaitGroup, application wiring, and readiness","50–65 minutes",[389,390,392],"h2",{"id":391},"what-you-will-learn","What you will learn",[394,395,396],"p",{},"By the end of this lesson, you will be able to:",[398,399,400,404,407,410,413],"ul",{},[401,402,403],"li",{},"convert process signals into cancellation;",[401,405,406],{},"distinguish stopping new work from completing active work;",[401,408,409],{},"coordinate HTTP, background workers, and owned resources;",[401,411,412],{},"apply a bounded shutdown deadline;",[401,414,415],{},"avoid common goroutine and deployment shutdown races.",[389,417,419],{"id":418},"mental-model-shutdown-is-a-state-transition","Mental model: shutdown is a state transition",[394,421,422],{},"A service does not jump directly from running to gone. A controlled shutdown normally moves through stages:",[424,425,431],"pre",{"className":426,"code":428,"language":429,"meta":430},[427],"language-text","ready\n  ↓ mark unready\ndraining\n  ↓ stop intake and wait\nstopping\n  ↓ close owned resources\nstopped\n","text","",[432,433,428],"code",{"__ignoreMap":430},[394,435,436],{},"The exact order depends on the service, but it must be intentional.",[389,438,440],{"id":439},"receive-cancellation-at-the-process-boundary","Receive cancellation at the process boundary",[424,442,446],{"className":443,"code":444,"language":445,"meta":430,"style":430},"language-go shiki shiki-themes solarized-light material-theme one-dark-pro","func main() {\n    ctx, stop := signal.NotifyContext(\n        context.Background(),\n        os.Interrupt,\n        syscall.SIGTERM,\n    )\n    defer stop()\n\n    if err := run(ctx); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}\n","go",[432,447,448,468,497,511,525,538,544,556,563,598,626,644,650],{"__ignoreMap":430},[449,450,453,457,461,465],"span",{"class":451,"line":452},"line",1,[449,454,456],{"class":455},"sEOdo","func",[449,458,460],{"class":459},"sisdC"," main",[449,462,464],{"class":463},"shFME","()",[449,466,467],{"class":463}," {\n",[449,469,471,475,478,481,485,488,491,494],{"class":451,"line":470},2,[449,472,474],{"class":473},"s45-6","    ctx",[449,476,477],{"class":463},",",[449,479,480],{"class":473}," stop",[449,482,484],{"class":483},"su2KV"," :=",[449,486,487],{"class":473}," signal",[449,489,490],{"class":463},".",[449,492,493],{"class":459},"NotifyContext",[449,495,496],{"class":463},"(\n",[449,498,500,503,505,508],{"class":451,"line":499},3,[449,501,502],{"class":473},"        context",[449,504,490],{"class":463},[449,506,507],{"class":459},"Background",[449,509,510],{"class":463},"(),\n",[449,512,514,517,519,522],{"class":451,"line":513},4,[449,515,516],{"class":473},"        os",[449,518,490],{"class":463},[449,520,521],{"class":473},"Interrupt",[449,523,524],{"class":463},",\n",[449,526,528,531,533,536],{"class":451,"line":527},5,[449,529,530],{"class":473},"        syscall",[449,532,490],{"class":463},[449,534,535],{"class":473},"SIGTERM",[449,537,524],{"class":463},[449,539,541],{"class":451,"line":540},6,[449,542,543],{"class":463},"    )\n",[449,545,547,551,553],{"class":451,"line":546},7,[449,548,550],{"class":549},"s7Bcg","    defer",[449,552,480],{"class":459},[449,554,555],{"class":463},"()\n",[449,557,559],{"class":451,"line":558},8,[449,560,562],{"emptyLinePlaceholder":561},true,"\n",[449,564,566,569,572,574,577,580,583,586,588,592,596],{"class":451,"line":565},9,[449,567,568],{"class":549},"    if",[449,570,571],{"class":473}," err",[449,573,484],{"class":483},[449,575,576],{"class":459}," run",[449,578,579],{"class":463},"(",[449,581,582],{"class":473},"ctx",[449,584,585],{"class":463},");",[449,587,571],{"class":473},[449,589,591],{"class":590},"sRBoR"," !=",[449,593,595],{"class":594},"sp8Z5"," nil",[449,597,467],{"class":463},[449,599,601,604,606,609,611,614,616,619,621,623],{"class":451,"line":600},10,[449,602,603],{"class":473},"        fmt",[449,605,490],{"class":463},[449,607,608],{"class":459},"Fprintln",[449,610,579],{"class":463},[449,612,613],{"class":473},"os",[449,615,490],{"class":463},[449,617,618],{"class":473},"Stderr",[449,620,477],{"class":463},[449,622,571],{"class":473},[449,624,625],{"class":463},")\n",[449,627,629,631,633,636,638,642],{"class":451,"line":628},11,[449,630,516],{"class":473},[449,632,490],{"class":463},[449,634,635],{"class":459},"Exit",[449,637,579],{"class":463},[449,639,641],{"class":640},"sAJzr","1",[449,643,625],{"class":463},[449,645,647],{"class":451,"line":646},12,[449,648,649],{"class":463},"    }\n",[449,651,653],{"class":451,"line":652},13,[449,654,655],{"class":463},"}\n",[394,657,658,660],{},[432,659,535],{}," is commonly used by process managers on Unix-like systems; signal availability and semantics vary by platform. The application context expresses the request to stop.",[389,662,664],{"id":663},"serve-and-wait-for-either-failure-or-cancellation","Serve and wait for either failure or cancellation",[424,666,668],{"className":443,"code":667,"language":445,"meta":430,"style":430},"func serve(ctx context.Context, server *http.Server) error {\n    serveErrors := make(chan error, 1)\n\n    go func() {\n        serveErrors \u003C- server.ListenAndServe()\n    }()\n\n    select {\n    case err := \u003C-serveErrors:\n        if errors.Is(err, http.ErrServerClosed) {\n            return nil\n        }\n        return fmt.Errorf(\"serve HTTP: %w\", err)\n\n    case \u003C-ctx.Done():\n        shutdownCtx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n        defer cancel()\n\n        if err := server.Shutdown(shutdownCtx); err != nil {\n            return fmt.Errorf(\"shutdown HTTP server: %w\", err)\n        }\n        return nil\n    }\n}\n",[432,669,670,716,740,744,756,773,778,782,789,806,838,846,851,886,891,908,956,966,971,1002,1030,1035,1042,1047],{"__ignoreMap":430},[449,671,672,674,677,679,682,686,688,691,693,696,699,702,704,707,710,714],{"class":451,"line":452},[449,673,456],{"class":455},[449,675,676],{"class":459}," serve",[449,678,579],{"class":463},[449,680,582],{"class":681},"syre3",[449,683,685],{"class":684},"snwKR"," context",[449,687,490],{"class":463},[449,689,690],{"class":684},"Context",[449,692,477],{"class":463},[449,694,695],{"class":681}," server",[449,697,698],{"class":455}," *",[449,700,701],{"class":684},"http",[449,703,490],{"class":463},[449,705,706],{"class":684},"Server",[449,708,709],{"class":463},")",[449,711,713],{"class":712},"sF6sA"," error",[449,715,467],{"class":463},[449,717,718,721,723,726,728,731,733,735,738],{"class":451,"line":470},[449,719,720],{"class":473},"    serveErrors",[449,722,484],{"class":483},[449,724,725],{"class":459}," make",[449,727,579],{"class":463},[449,729,730],{"class":455},"chan",[449,732,713],{"class":712},[449,734,477],{"class":463},[449,736,737],{"class":640}," 1",[449,739,625],{"class":463},[449,741,742],{"class":451,"line":499},[449,743,562],{"emptyLinePlaceholder":561},[449,745,746,749,752,754],{"class":451,"line":513},[449,747,748],{"class":549},"    go",[449,750,751],{"class":455}," func",[449,753,464],{"class":463},[449,755,467],{"class":463},[449,757,758,761,764,766,768,771],{"class":451,"line":527},[449,759,760],{"class":473},"        serveErrors",[449,762,763],{"class":590}," \u003C-",[449,765,695],{"class":473},[449,767,490],{"class":463},[449,769,770],{"class":459},"ListenAndServe",[449,772,555],{"class":463},[449,774,775],{"class":451,"line":540},[449,776,777],{"class":463},"    }()\n",[449,779,780],{"class":451,"line":546},[449,781,562],{"emptyLinePlaceholder":561},[449,783,784,787],{"class":451,"line":558},[449,785,786],{"class":549},"    select",[449,788,467],{"class":463},[449,790,791,794,796,798,800,803],{"class":451,"line":565},[449,792,793],{"class":549},"    case",[449,795,571],{"class":473},[449,797,484],{"class":483},[449,799,763],{"class":590},[449,801,802],{"class":473},"serveErrors",[449,804,805],{"class":463},":\n",[449,807,808,811,814,816,819,821,824,826,829,831,834,836],{"class":451,"line":600},[449,809,810],{"class":549},"        if",[449,812,813],{"class":473}," errors",[449,815,490],{"class":463},[449,817,818],{"class":459},"Is",[449,820,579],{"class":463},[449,822,823],{"class":473},"err",[449,825,477],{"class":463},[449,827,828],{"class":473}," http",[449,830,490],{"class":463},[449,832,833],{"class":473},"ErrServerClosed",[449,835,709],{"class":463},[449,837,467],{"class":463},[449,839,840,843],{"class":451,"line":628},[449,841,842],{"class":549},"            return",[449,844,845],{"class":594}," nil\n",[449,847,848],{"class":451,"line":646},[449,849,850],{"class":463},"        }\n",[449,852,853,856,859,861,864,866,870,874,878,880,882,884],{"class":451,"line":652},[449,854,855],{"class":549},"        return",[449,857,858],{"class":473}," fmt",[449,860,490],{"class":463},[449,862,863],{"class":459},"Errorf",[449,865,579],{"class":463},[449,867,869],{"class":868},"sED5a","\"",[449,871,873],{"class":872},"sVazx","serve HTTP: ",[449,875,877],{"class":876},"st3jj","%w",[449,879,869],{"class":868},[449,881,477],{"class":463},[449,883,571],{"class":473},[449,885,625],{"class":463},[449,887,889],{"class":451,"line":888},14,[449,890,562],{"emptyLinePlaceholder":561},[449,892,894,896,898,900,902,905],{"class":451,"line":893},15,[449,895,793],{"class":549},[449,897,763],{"class":590},[449,899,582],{"class":473},[449,901,490],{"class":463},[449,903,904],{"class":459},"Done",[449,906,907],{"class":463},"():\n",[449,909,911,914,916,919,921,923,925,928,930,933,935,937,940,943,946,949,951,954],{"class":451,"line":910},16,[449,912,913],{"class":473},"        shutdownCtx",[449,915,477],{"class":463},[449,917,918],{"class":473}," cancel",[449,920,484],{"class":483},[449,922,685],{"class":473},[449,924,490],{"class":463},[449,926,927],{"class":459},"WithTimeout",[449,929,579],{"class":463},[449,931,932],{"class":473},"context",[449,934,490],{"class":463},[449,936,507],{"class":459},[449,938,939],{"class":463},"(),",[449,941,942],{"class":640}," 15",[449,944,945],{"class":455},"*",[449,947,948],{"class":473},"time",[449,950,490],{"class":463},[449,952,953],{"class":473},"Second",[449,955,625],{"class":463},[449,957,959,962,964],{"class":451,"line":958},17,[449,960,961],{"class":549},"        defer",[449,963,918],{"class":459},[449,965,555],{"class":463},[449,967,969],{"class":451,"line":968},18,[449,970,562],{"emptyLinePlaceholder":561},[449,972,974,976,978,980,982,984,987,989,992,994,996,998,1000],{"class":451,"line":973},19,[449,975,810],{"class":549},[449,977,571],{"class":473},[449,979,484],{"class":483},[449,981,695],{"class":473},[449,983,490],{"class":463},[449,985,986],{"class":459},"Shutdown",[449,988,579],{"class":463},[449,990,991],{"class":473},"shutdownCtx",[449,993,585],{"class":463},[449,995,571],{"class":473},[449,997,591],{"class":590},[449,999,595],{"class":594},[449,1001,467],{"class":463},[449,1003,1005,1007,1009,1011,1013,1015,1017,1020,1022,1024,1026,1028],{"class":451,"line":1004},20,[449,1006,842],{"class":549},[449,1008,858],{"class":473},[449,1010,490],{"class":463},[449,1012,863],{"class":459},[449,1014,579],{"class":463},[449,1016,869],{"class":868},[449,1018,1019],{"class":872},"shutdown HTTP server: ",[449,1021,877],{"class":876},[449,1023,869],{"class":868},[449,1025,477],{"class":463},[449,1027,571],{"class":473},[449,1029,625],{"class":463},[449,1031,1033],{"class":451,"line":1032},21,[449,1034,850],{"class":463},[449,1036,1038,1040],{"class":451,"line":1037},22,[449,1039,855],{"class":549},[449,1041,845],{"class":594},[449,1043,1045],{"class":451,"line":1044},23,[449,1046,649],{"class":463},[449,1048,1050],{"class":451,"line":1049},24,[449,1051,655],{"class":463},[394,1053,1054,1056],{},[432,1055,986],{}," closes listeners, closes idle connections, and waits for active connections to become idle, bounded by the context. It does not wait for every possible hijacked or upgraded connection; applications using those features must coordinate them separately.",[394,1058,1059],{},"Use a fresh bounded context for cleanup. The main application context is already cancelled.",[389,1061,1063],{"id":1062},"mark-unready-before-draining","Mark unready before draining",[394,1065,1066],{},"In an orchestrated deployment:",[1068,1069,1070,1073,1076,1079],"ol",{},[401,1071,1072],{},"Mark the instance unready.",[401,1074,1075],{},"Allow routing state to propagate for a short, configured drain period if the platform requires it.",[401,1077,1078],{},"Stop accepting new connections or requests.",[401,1080,1081],{},"Wait for active requests within the shutdown budget.",[394,1083,1084],{},"The total must fit inside the platform's termination grace period. Do not guess: configure and test it in the actual environment.",[389,1086,1088],{"id":1087},"stop-background-workers","Stop background workers",[424,1090,1092],{"className":443,"code":1091,"language":445,"meta":430,"style":430},"type WorkerGroup struct {\n    cancel context.CancelFunc\n    wait   sync.WaitGroup\n}\n\nfunc (g *WorkerGroup) Start(parent context.Context, worker func(context.Context)) {\n    ctx, cancel := context.WithCancel(parent)\n    g.cancel = cancel\n    g.wait.Add(1)\n    go func() {\n        defer g.wait.Done()\n        worker(ctx)\n    }()\n}\n\nfunc (g *WorkerGroup) Stop() {\n    if g.cancel != nil {\n        g.cancel()\n    }\n    g.wait.Wait()\n}\n",[432,1093,1094,1107,1119,1132,1136,1140,1191,1214,1230,1250,1260,1277,1288,1292,1296,1300,1321,1337,1348,1352,1367],{"__ignoreMap":430},[449,1095,1096,1099,1102,1105],{"class":451,"line":452},[449,1097,1098],{"class":455},"type",[449,1100,1101],{"class":684}," WorkerGroup",[449,1103,1104],{"class":455}," struct",[449,1106,467],{"class":463},[449,1108,1109,1112,1114,1116],{"class":451,"line":470},[449,1110,1111],{"class":473},"    cancel",[449,1113,685],{"class":684},[449,1115,490],{"class":463},[449,1117,1118],{"class":684},"CancelFunc\n",[449,1120,1121,1124,1127,1129],{"class":451,"line":499},[449,1122,1123],{"class":473},"    wait",[449,1125,1126],{"class":684},"   sync",[449,1128,490],{"class":463},[449,1130,1131],{"class":684},"WaitGroup\n",[449,1133,1134],{"class":451,"line":513},[449,1135,655],{"class":463},[449,1137,1138],{"class":451,"line":527},[449,1139,562],{"emptyLinePlaceholder":561},[449,1141,1142,1144,1147,1150,1152,1155,1157,1160,1162,1165,1167,1169,1171,1173,1176,1178,1180,1182,1184,1186,1189],{"class":451,"line":540},[449,1143,456],{"class":455},[449,1145,1146],{"class":463}," (",[449,1148,1149],{"class":681},"g ",[449,1151,945],{"class":455},[449,1153,1154],{"class":684},"WorkerGroup",[449,1156,709],{"class":463},[449,1158,1159],{"class":459}," Start",[449,1161,579],{"class":463},[449,1163,1164],{"class":681},"parent",[449,1166,685],{"class":684},[449,1168,490],{"class":463},[449,1170,690],{"class":684},[449,1172,477],{"class":463},[449,1174,1175],{"class":681}," worker",[449,1177,751],{"class":455},[449,1179,579],{"class":463},[449,1181,932],{"class":684},[449,1183,490],{"class":463},[449,1185,690],{"class":684},[449,1187,1188],{"class":463},"))",[449,1190,467],{"class":463},[449,1192,1193,1195,1197,1199,1201,1203,1205,1208,1210,1212],{"class":451,"line":546},[449,1194,474],{"class":473},[449,1196,477],{"class":463},[449,1198,918],{"class":473},[449,1200,484],{"class":483},[449,1202,685],{"class":473},[449,1204,490],{"class":463},[449,1206,1207],{"class":459},"WithCancel",[449,1209,579],{"class":463},[449,1211,1164],{"class":473},[449,1213,625],{"class":463},[449,1215,1216,1219,1221,1224,1227],{"class":451,"line":558},[449,1217,1218],{"class":473},"    g",[449,1220,490],{"class":463},[449,1222,1223],{"class":473},"cancel",[449,1225,1226],{"class":483}," =",[449,1228,1229],{"class":473}," cancel\n",[449,1231,1232,1234,1236,1239,1241,1244,1246,1248],{"class":451,"line":565},[449,1233,1218],{"class":473},[449,1235,490],{"class":463},[449,1237,1238],{"class":473},"wait",[449,1240,490],{"class":463},[449,1242,1243],{"class":459},"Add",[449,1245,579],{"class":463},[449,1247,641],{"class":640},[449,1249,625],{"class":463},[449,1251,1252,1254,1256,1258],{"class":451,"line":600},[449,1253,748],{"class":549},[449,1255,751],{"class":455},[449,1257,464],{"class":463},[449,1259,467],{"class":463},[449,1261,1262,1264,1267,1269,1271,1273,1275],{"class":451,"line":628},[449,1263,961],{"class":549},[449,1265,1266],{"class":473}," g",[449,1268,490],{"class":463},[449,1270,1238],{"class":473},[449,1272,490],{"class":463},[449,1274,904],{"class":459},[449,1276,555],{"class":463},[449,1278,1279,1282,1284,1286],{"class":451,"line":646},[449,1280,1281],{"class":459},"        worker",[449,1283,579],{"class":463},[449,1285,582],{"class":473},[449,1287,625],{"class":463},[449,1289,1290],{"class":451,"line":652},[449,1291,777],{"class":463},[449,1293,1294],{"class":451,"line":888},[449,1295,655],{"class":463},[449,1297,1298],{"class":451,"line":893},[449,1299,562],{"emptyLinePlaceholder":561},[449,1301,1302,1304,1306,1308,1310,1312,1314,1317,1319],{"class":451,"line":910},[449,1303,456],{"class":455},[449,1305,1146],{"class":463},[449,1307,1149],{"class":681},[449,1309,945],{"class":455},[449,1311,1154],{"class":684},[449,1313,709],{"class":463},[449,1315,1316],{"class":459}," Stop",[449,1318,464],{"class":463},[449,1320,467],{"class":463},[449,1322,1323,1325,1327,1329,1331,1333,1335],{"class":451,"line":958},[449,1324,568],{"class":549},[449,1326,1266],{"class":473},[449,1328,490],{"class":463},[449,1330,1223],{"class":473},[449,1332,591],{"class":590},[449,1334,595],{"class":594},[449,1336,467],{"class":463},[449,1338,1339,1342,1344,1346],{"class":451,"line":968},[449,1340,1341],{"class":473},"        g",[449,1343,490],{"class":463},[449,1345,1223],{"class":459},[449,1347,555],{"class":463},[449,1349,1350],{"class":451,"line":973},[449,1351,649],{"class":463},[449,1353,1354,1356,1358,1360,1362,1365],{"class":451,"line":1004},[449,1355,1218],{"class":473},[449,1357,490],{"class":463},[449,1359,1238],{"class":473},[449,1361,490],{"class":463},[449,1363,1364],{"class":459},"Wait",[449,1366,555],{"class":463},[449,1368,1369],{"class":451,"line":1032},[449,1370,655],{"class":463},[394,1372,1373,1374,1377],{},"Real groups need clear rules for multiple workers, repeated calls, startup failures, and bounded waiting. A worker must actually observe ",[432,1375,1376],{},"ctx.Done()"," around blocking operations.",[389,1379,1381],{"id":1380},"choose-shutdown-order-from-ownership","Choose shutdown order from ownership",[394,1383,1384],{},"A common order is:",[1068,1386,1387,1390,1393,1396,1399,1402,1405],{},[401,1388,1389],{},"mark unready;",[401,1391,1392],{},"stop external intake;",[401,1394,1395],{},"wait for active handlers;",[401,1397,1398],{},"cancel internal producers;",[401,1400,1401],{},"let consumers drain or stop according to delivery guarantees;",[401,1403,1404],{},"flush bounded telemetry;",[401,1406,1407],{},"close database and other owned clients.",[394,1409,1410,1411,1414],{},"If handlers still need the database while draining, closing it before ",[432,1412,1413],{},"server.Shutdown"," completes creates failures. Ownership and dependency direction determine the order.",[389,1416,1418],{"id":1417},"delivery-semantics-matter","Delivery semantics matter",[394,1420,1421],{},"A queue worker may need to acknowledge a job only after durable completion. Cancellation halfway through must not falsely mark it successful. Design jobs to be idempotent when redelivery is possible.",[394,1423,1424],{},"Shutdown cannot guarantee completion after a hard process kill or machine failure. Durable systems need recovery and replay semantics, not only graceful process code.",[389,1426,1428],{"id":1427},"common-mistakes","Common mistakes",[398,1430,1431,1442,1448,1454,1460,1470],{},[401,1432,1433,1441],{},[1434,1435,1436,1437,1440],"strong",{},"Calling ",[432,1438,1439],{},"server.Close"," first:"," active connections are closed immediately instead of drained.",[401,1443,1444,1447],{},[1434,1445,1446],{},"Using the cancelled request context for cleanup:"," cleanup ends immediately.",[401,1449,1450,1453],{},[1434,1451,1452],{},"Closing the database before handlers finish:"," in-flight requests fail during the drain.",[401,1455,1456,1459],{},[1434,1457,1458],{},"Waiting forever:"," deployments hang because one dependency or goroutine never returns.",[401,1461,1462,1469],{},[1434,1463,1464,1465,1468],{},"Using ",[432,1466,1467],{},"time.Sleep"," as worker coordination:"," completion remains unknown.",[401,1471,1472,1475],{},[1434,1473,1474],{},"Assuming graceful shutdown covers crashes:"," durable recovery is still required.",[389,1477,1479],{"id":1478},"practice","Practice",[394,1481,1482],{},"Build a service with one HTTP server and two background workers. On cancellation, mark readiness false, drain HTTP within ten seconds, cancel workers, wait for them within the remaining budget, then close storage. Record each transition.",[1484,1485,1486],"accordion",{},[1487,1488,1491,1888],"accordion-item",{"icon":1489,"label":1490},"i-lucide-lightbulb","Show orchestration outline",[424,1492,1494],{"className":443,"code":1493,"language":445,"meta":430,"style":430},"func (a *Application) Shutdown() error {\n    a.readiness.Set(false)\n\n    ctx, cancel := context.WithTimeout(context.Background(), a.shutdownTimeout)\n    defer cancel()\n\n    var problems []error\n    if err := a.server.Shutdown(ctx); err != nil {\n        problems = append(problems, fmt.Errorf(\"HTTP shutdown: %w\", err))\n    }\n\n    a.cancelWorkers()\n    if err := waitGroupContext(ctx, &a.workers); err != nil {\n        problems = append(problems, fmt.Errorf(\"worker shutdown: %w\", err))\n    }\n\n    if err := a.database.Close(); err != nil {\n        problems = append(problems, fmt.Errorf(\"close database: %w\", err))\n    }\n\n    return errors.Join(problems...)\n}\n",[432,1495,1496,1521,1544,1548,1584,1592,1596,1610,1643,1684,1688,1692,1703,1741,1778,1782,1786,1817,1854,1858,1862,1884],{"__ignoreMap":430},[449,1497,1498,1500,1502,1505,1507,1510,1512,1515,1517,1519],{"class":451,"line":452},[449,1499,456],{"class":455},[449,1501,1146],{"class":463},[449,1503,1504],{"class":681},"a ",[449,1506,945],{"class":455},[449,1508,1509],{"class":684},"Application",[449,1511,709],{"class":463},[449,1513,1514],{"class":459}," Shutdown",[449,1516,464],{"class":463},[449,1518,713],{"class":712},[449,1520,467],{"class":463},[449,1522,1523,1526,1528,1531,1533,1536,1538,1542],{"class":451,"line":470},[449,1524,1525],{"class":473},"    a",[449,1527,490],{"class":463},[449,1529,1530],{"class":473},"readiness",[449,1532,490],{"class":463},[449,1534,1535],{"class":459},"Set",[449,1537,579],{"class":463},[449,1539,1541],{"class":1540},"sqQ1y","false",[449,1543,625],{"class":463},[449,1545,1546],{"class":451,"line":499},[449,1547,562],{"emptyLinePlaceholder":561},[449,1549,1550,1552,1554,1556,1558,1560,1562,1564,1566,1568,1570,1572,1574,1577,1579,1582],{"class":451,"line":513},[449,1551,474],{"class":473},[449,1553,477],{"class":463},[449,1555,918],{"class":473},[449,1557,484],{"class":483},[449,1559,685],{"class":473},[449,1561,490],{"class":463},[449,1563,927],{"class":459},[449,1565,579],{"class":463},[449,1567,932],{"class":473},[449,1569,490],{"class":463},[449,1571,507],{"class":459},[449,1573,939],{"class":463},[449,1575,1576],{"class":473}," a",[449,1578,490],{"class":463},[449,1580,1581],{"class":473},"shutdownTimeout",[449,1583,625],{"class":463},[449,1585,1586,1588,1590],{"class":451,"line":527},[449,1587,550],{"class":549},[449,1589,918],{"class":459},[449,1591,555],{"class":463},[449,1593,1594],{"class":451,"line":540},[449,1595,562],{"emptyLinePlaceholder":561},[449,1597,1598,1601,1604,1607],{"class":451,"line":546},[449,1599,1600],{"class":455},"    var",[449,1602,1603],{"class":473}," problems",[449,1605,1606],{"class":463}," []",[449,1608,1609],{"class":712},"error\n",[449,1611,1612,1614,1616,1618,1620,1622,1625,1627,1629,1631,1633,1635,1637,1639,1641],{"class":451,"line":558},[449,1613,568],{"class":549},[449,1615,571],{"class":473},[449,1617,484],{"class":483},[449,1619,1576],{"class":473},[449,1621,490],{"class":463},[449,1623,1624],{"class":473},"server",[449,1626,490],{"class":463},[449,1628,986],{"class":459},[449,1630,579],{"class":463},[449,1632,582],{"class":473},[449,1634,585],{"class":463},[449,1636,571],{"class":473},[449,1638,591],{"class":590},[449,1640,595],{"class":594},[449,1642,467],{"class":463},[449,1644,1645,1648,1650,1653,1655,1658,1660,1662,1664,1666,1668,1670,1673,1675,1677,1679,1681],{"class":451,"line":565},[449,1646,1647],{"class":473},"        problems",[449,1649,1226],{"class":483},[449,1651,1652],{"class":459}," append",[449,1654,579],{"class":463},[449,1656,1657],{"class":473},"problems",[449,1659,477],{"class":463},[449,1661,858],{"class":473},[449,1663,490],{"class":463},[449,1665,863],{"class":459},[449,1667,579],{"class":463},[449,1669,869],{"class":868},[449,1671,1672],{"class":872},"HTTP shutdown: ",[449,1674,877],{"class":876},[449,1676,869],{"class":868},[449,1678,477],{"class":463},[449,1680,571],{"class":473},[449,1682,1683],{"class":463},"))\n",[449,1685,1686],{"class":451,"line":600},[449,1687,649],{"class":463},[449,1689,1690],{"class":451,"line":628},[449,1691,562],{"emptyLinePlaceholder":561},[449,1693,1694,1696,1698,1701],{"class":451,"line":646},[449,1695,1525],{"class":473},[449,1697,490],{"class":463},[449,1699,1700],{"class":459},"cancelWorkers",[449,1702,555],{"class":463},[449,1704,1705,1707,1709,1711,1714,1716,1718,1720,1723,1726,1728,1731,1733,1735,1737,1739],{"class":451,"line":652},[449,1706,568],{"class":549},[449,1708,571],{"class":473},[449,1710,484],{"class":483},[449,1712,1713],{"class":459}," waitGroupContext",[449,1715,579],{"class":463},[449,1717,582],{"class":473},[449,1719,477],{"class":463},[449,1721,1722],{"class":455}," &",[449,1724,1725],{"class":473},"a",[449,1727,490],{"class":463},[449,1729,1730],{"class":473},"workers",[449,1732,585],{"class":463},[449,1734,571],{"class":473},[449,1736,591],{"class":590},[449,1738,595],{"class":594},[449,1740,467],{"class":463},[449,1742,1743,1745,1747,1749,1751,1753,1755,1757,1759,1761,1763,1765,1768,1770,1772,1774,1776],{"class":451,"line":888},[449,1744,1647],{"class":473},[449,1746,1226],{"class":483},[449,1748,1652],{"class":459},[449,1750,579],{"class":463},[449,1752,1657],{"class":473},[449,1754,477],{"class":463},[449,1756,858],{"class":473},[449,1758,490],{"class":463},[449,1760,863],{"class":459},[449,1762,579],{"class":463},[449,1764,869],{"class":868},[449,1766,1767],{"class":872},"worker shutdown: ",[449,1769,877],{"class":876},[449,1771,869],{"class":868},[449,1773,477],{"class":463},[449,1775,571],{"class":473},[449,1777,1683],{"class":463},[449,1779,1780],{"class":451,"line":893},[449,1781,649],{"class":463},[449,1783,1784],{"class":451,"line":910},[449,1785,562],{"emptyLinePlaceholder":561},[449,1787,1788,1790,1792,1794,1796,1798,1801,1803,1806,1809,1811,1813,1815],{"class":451,"line":958},[449,1789,568],{"class":549},[449,1791,571],{"class":473},[449,1793,484],{"class":483},[449,1795,1576],{"class":473},[449,1797,490],{"class":463},[449,1799,1800],{"class":473},"database",[449,1802,490],{"class":463},[449,1804,1805],{"class":459},"Close",[449,1807,1808],{"class":463},"();",[449,1810,571],{"class":473},[449,1812,591],{"class":590},[449,1814,595],{"class":594},[449,1816,467],{"class":463},[449,1818,1819,1821,1823,1825,1827,1829,1831,1833,1835,1837,1839,1841,1844,1846,1848,1850,1852],{"class":451,"line":968},[449,1820,1647],{"class":473},[449,1822,1226],{"class":483},[449,1824,1652],{"class":459},[449,1826,579],{"class":463},[449,1828,1657],{"class":473},[449,1830,477],{"class":463},[449,1832,858],{"class":473},[449,1834,490],{"class":463},[449,1836,863],{"class":459},[449,1838,579],{"class":463},[449,1840,869],{"class":868},[449,1842,1843],{"class":872},"close database: ",[449,1845,877],{"class":876},[449,1847,869],{"class":868},[449,1849,477],{"class":463},[449,1851,571],{"class":473},[449,1853,1683],{"class":463},[449,1855,1856],{"class":451,"line":973},[449,1857,649],{"class":463},[449,1859,1860],{"class":451,"line":1004},[449,1861,562],{"emptyLinePlaceholder":561},[449,1863,1864,1867,1869,1871,1874,1876,1878,1882],{"class":451,"line":1032},[449,1865,1866],{"class":549},"    return",[449,1868,813],{"class":473},[449,1870,490],{"class":463},[449,1872,1873],{"class":459},"Join",[449,1875,579],{"class":463},[449,1877,1657],{"class":473},[449,1879,1881],{"class":1880},"sN42N","...",[449,1883,625],{"class":463},[449,1885,1886],{"class":451,"line":1037},[449,1887,655],{"class":463},[394,1889,1890,1893,1894,1897,1898,1900,1901,1903],{},[432,1891,1892],{},"waitGroupContext"," requires careful implementation because ",[432,1895,1896],{},"sync.WaitGroup"," has no context-aware wait method. One approach has a helper goroutine close a channel after ",[432,1899,1364],{},"; select between that channel and ",[432,1902,1376],{},". Ensure repeated shutdown is safe, and decide whether a timed-out process should return for the process manager to enforce its hard deadline.",[389,1905,1907],{"id":1906},"summary","Summary",[398,1909,1910,1913,1916,1919,1922],{},[401,1911,1912],{},"Shutdown is an ordered transition, not one function call.",[401,1914,1915],{},"Mark unready and stop intake before releasing dependencies.",[401,1917,1918],{},"Use a new bounded context for cleanup after cancellation.",[401,1920,1921],{},"Coordinate every goroutine and blocking operation with an explicit stop path.",[401,1923,1924],{},"Durable recovery and idempotency are still needed for crashes and hard kills.",[1926,1927],"learning-lesson-complete",{},[1929,1930],"learning-lesson-navigation",{"next":201,"next-label":200,"previous":241,"previous-label":240},[1932,1933,1934],"style",{},"html pre.shiki code .sEOdo, html code.shiki .sEOdo{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#C678DD}html pre.shiki code .sisdC, html code.shiki .sisdC{--shiki-light:#268BD2;--shiki-default:#82AAFF;--shiki-dark:#61AFEF}html pre.shiki code .shFME, html code.shiki .shFME{--shiki-light:#657B83;--shiki-default:#89DDFF;--shiki-dark:#ABB2BF}html pre.shiki code .s45-6, html code.shiki .s45-6{--shiki-light:#268BD2;--shiki-default:#EEFFFF;--shiki-dark:#E06C75}html pre.shiki code .su2KV, html code.shiki .su2KV{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#E5C07B}html pre.shiki code .s7Bcg, html code.shiki .s7Bcg{--shiki-light:#859900;--shiki-light-font-style:inherit;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#C678DD;--shiki-dark-font-style:inherit}html pre.shiki code .sRBoR, html code.shiki .sRBoR{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#56B6C2}html pre.shiki code .sp8Z5, html code.shiki .sp8Z5{--shiki-light:#B58900;--shiki-default:#89DDFF;--shiki-dark:#D19A66}html pre.shiki code .sAJzr, html code.shiki .sAJzr{--shiki-light:#D33682;--shiki-default:#F78C6C;--shiki-dark:#D19A66}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .syre3, html code.shiki .syre3{--shiki-light:#657B83;--shiki-light-font-style:inherit;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#E06C75;--shiki-dark-font-style:italic}html pre.shiki code .snwKR, html code.shiki .snwKR{--shiki-light:#CB4B16;--shiki-default:#FFCB6B;--shiki-dark:#E5C07B}html pre.shiki code .sF6sA, html code.shiki .sF6sA{--shiki-light:#586E75;--shiki-light-font-weight:bold;--shiki-default:#C792EA;--shiki-default-font-weight:inherit;--shiki-dark:#C678DD;--shiki-dark-font-weight:inherit}html pre.shiki code .sED5a, html code.shiki .sED5a{--shiki-light:#2AA198;--shiki-default:#89DDFF;--shiki-dark:#98C379}html pre.shiki code .sVazx, html code.shiki .sVazx{--shiki-light:#2AA198;--shiki-default:#C3E88D;--shiki-dark:#98C379}html pre.shiki code .st3jj, html code.shiki .st3jj{--shiki-light:#CB4B16;--shiki-default:#F07178;--shiki-dark:#D19A66}html pre.shiki code .sqQ1y, html code.shiki .sqQ1y{--shiki-light:#B58900;--shiki-default:#FF9CAC;--shiki-dark:#D19A66}html pre.shiki code .sN42N, html code.shiki .sN42N{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#ABB2BF}",{"title":430,"searchDepth":470,"depth":470,"links":1936},[1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947],{"id":391,"depth":470,"text":392},{"id":418,"depth":470,"text":419},{"id":439,"depth":470,"text":440},{"id":663,"depth":470,"text":664},{"id":1062,"depth":470,"text":1063},{"id":1087,"depth":470,"text":1088},{"id":1380,"depth":470,"text":1381},{"id":1417,"depth":470,"text":1418},{"id":1427,"depth":470,"text":1428},{"id":1478,"depth":470,"text":1479},{"id":1906,"depth":470,"text":1907},"Stop accepting work, drain active requests, cancel background tasks, and release resources in order.","md",null,{},{"icon":198},{"description":1954,"title":195},"Learn graceful Go service shutdown with signals, http.Server.Shutdown, readiness, context cancellation, goroutine coordination, and deadlines.","sr_ACTVLTsAQ6IYe2v6S56QRYEnziJbzQe2JrWvxTBQ",[1957,1959],{"title":190,"path":191,"stem":192,"description":1958,"icon":193,"children":-1},"Connect Go fundamentals to a production-style service without skipping the engineering boundaries.",{"title":200,"path":201,"stem":202,"description":1960,"icon":203,"children":-1},"Review correctness, security, operability, deployment, and recovery before serving real traffic.",1794118101033]