[{"data":1,"prerenderedAt":742},["Reactive",2],{"content-query-kagkTiAnnK":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"head":10,"layout":12,"body":13,"_type":737,"_id":738,"_source":739,"_file":740,"_extension":741},"/docs/guide/using-healthchecks-with-laravel","guide",false,"","Native Docker Health Checks for Laravel","Stop guessing if Laravel is up and running. Our health checks have you covered to ensure Laravel is running properly. It supports HTTP checks, Laravel Horizon, Reverb, Scheduler, and Queue.",{"title":11},"Native Docker Health Checks for Laravel - Docker PHP - Server Side Up","docs",{"type":14,"children":15,"toc":724},"root",[16,24,34,41,46,52,89,95,100,102,214,245,251,280,289,311,316,322,327,334,347,359,427,436,442,463,473,523,532,538,556,566,616,625,631,649,659,709,718],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"native-docker-health-checks-for-laravel",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"lead-p",{},[28],{"type":17,"tag":29,"props":30,"children":31},"p",{},[32],{"type":23,"value":33},"Dialing in health checks are very important for ensuring your application is running smoothly and that you're able to deploy updates without any downtime. This guide will explain how our health checks work and how you can use them to your advantage.",{"type":17,"tag":35,"props":36,"children":38},"h2",{"id":37},"what-are-health-checks",[39],{"type":23,"value":40},"What are Health Checks?",{"type":17,"tag":29,"props":42,"children":43},{},[44],{"type":23,"value":45},"Health checks are a way to check the status of your application. Whenever a container is started, a health check is performed. If the health check fails, the container will be restarted or marked as unhealthy. Health checks are very important for rolling updates and ensuring your application can start up in order if you have services that depend on each other.",{"type":17,"tag":35,"props":47,"children":49},{"id":48},"our-health-checks",[50],{"type":23,"value":51},"Our Health Checks",{"type":17,"tag":29,"props":53,"children":54},{},[55,57,64,66,79,81,87],{"type":23,"value":56},"We offer a number of health check commands, specifically for Laravel. You can find these commands are prefixed with ",{"type":17,"tag":58,"props":59,"children":61},"code",{"className":60},[],[62],{"type":23,"value":63},"healthcheck-",{"type":23,"value":65}," and are located in ",{"type":17,"tag":67,"props":68,"children":72},"a",{"href":69,"rel":70},"https://github.com/serversideup/docker-php/tree/main/src/common/usr/local/bin",[71],"nofollow",[73],{"type":17,"tag":58,"props":74,"children":76},{"className":75},[],[77],{"type":23,"value":78},"/usr/local/bin",{"type":23,"value":80},". The examples below show how to use these health checks in your ",{"type":17,"tag":58,"props":82,"children":84},{"className":83},[],[85],{"type":23,"value":86},"docker-compose.yml",{"type":23,"value":88}," file, but you can also use them in other environments.",{"type":17,"tag":35,"props":90,"children":92},{"id":91},"default-health-check-settings",[93],{"type":23,"value":94},"Default Health Check Settings",{"type":17,"tag":29,"props":96,"children":97},{},[98],{"type":23,"value":99},"By default, our Dockerfiles ship with the following health check commands:",{"type":23,"value":101},"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",{"type":17,"tag":103,"props":104,"children":105},"table",{},[106,125],{"type":17,"tag":107,"props":108,"children":109},"thead",{},[110],{"type":17,"tag":111,"props":112,"children":113},"tr",{},[114,120],{"type":17,"tag":115,"props":116,"children":117},"th",{},[118],{"type":23,"value":119},"Variation",{"type":17,"tag":115,"props":121,"children":122},{},[123],{"type":23,"value":124},"Health Check Command",{"type":17,"tag":126,"props":127,"children":128},"tbody",{},[129,147,173,194],{"type":17,"tag":111,"props":130,"children":131},{},[132,142],{"type":17,"tag":133,"props":134,"children":135},"td",{},[136],{"type":17,"tag":58,"props":137,"children":139},{"className":138},[],[140],{"type":23,"value":141},"cli",{"type":17,"tag":133,"props":143,"children":144},{},[145],{"type":23,"value":146},"(none)",{"type":17,"tag":111,"props":148,"children":149},{},[150,159],{"type":17,"tag":133,"props":151,"children":152},{},[153],{"type":17,"tag":58,"props":154,"children":156},{"className":155},[],[157],{"type":23,"value":158},"fpm",{"type":17,"tag":133,"props":160,"children":161},{},[162],{"type":17,"tag":67,"props":163,"children":166},{"href":164,"rel":165},"https://github.com/renatomefi/php-fpm-healthcheck",[71],[167],{"type":17,"tag":58,"props":168,"children":170},{"className":169},[],[171],{"type":23,"value":172},"php-fpm-healthcheck",{"type":17,"tag":111,"props":174,"children":175},{},[176,185],{"type":17,"tag":133,"props":177,"children":178},{},[179],{"type":17,"tag":58,"props":180,"children":182},{"className":181},[],[183],{"type":23,"value":184},"fpm-apache",{"type":17,"tag":133,"props":186,"children":187},{},[188],{"type":17,"tag":58,"props":189,"children":191},{"className":190},[],[192],{"type":23,"value":193},"curl --insecure --silent --location --show-error --fail http://localhost:8080$HEALTHCHECK_PATH",{"type":17,"tag":111,"props":195,"children":196},{},[197,206],{"type":17,"tag":133,"props":198,"children":199},{},[200],{"type":17,"tag":58,"props":201,"children":203},{"className":202},[],[204],{"type":23,"value":205},"fpm-nginx",{"type":17,"tag":133,"props":207,"children":208},{},[209],{"type":17,"tag":58,"props":210,"children":212},{"className":211},[],[213],{"type":23,"value":193},{"type":17,"tag":215,"props":216,"children":217},"note",{},[218],{"type":17,"tag":29,"props":219,"children":220},{},[221,223,228,230,235,237,243],{"type":23,"value":222},"Notice how ",{"type":17,"tag":58,"props":224,"children":226},{"className":225},[],[227],{"type":23,"value":184},{"type":23,"value":229}," and ",{"type":17,"tag":58,"props":231,"children":233},{"className":232},[],[234],{"type":23,"value":205},{"type":23,"value":236}," have a ",{"type":17,"tag":58,"props":238,"children":240},{"className":239},[],[241],{"type":23,"value":242},"$HEALTHCHECK_PATH",{"type":23,"value":244}," variable? This is because you can specify a path for the health check to validate.",{"type":17,"tag":35,"props":246,"children":248},{"id":247},"changing-the-health-check-path",[249],{"type":23,"value":250},"Changing the Health Check Path",{"type":17,"tag":29,"props":252,"children":253},{},[254,256,262,264,270,272,278],{"type":23,"value":255},"By default, you can see our ",{"type":17,"tag":67,"props":257,"children":259},{"href":258},"/docs/reference/environment-variable-specification",[260],{"type":23,"value":261},"Environment Variable Specification",{"type":23,"value":263}," shows the ",{"type":17,"tag":58,"props":265,"children":267},{"className":266},[],[268],{"type":23,"value":269},"HEALTHCHECK_PATH",{"type":23,"value":271}," variabe is set to ",{"type":17,"tag":58,"props":273,"children":275},{"className":274},[],[276],{"type":23,"value":277},"/healthcheck",{"type":23,"value":279},".",{"type":17,"tag":29,"props":281,"children":282},{},[283],{"type":17,"tag":284,"props":285,"children":286},"strong",{},[287],{"type":23,"value":288},"This only validates that FPM-NGINX or FPM-APACHE are running and ready to accept connections. It does not validate that Laravel is running or healthy.",{"type":17,"tag":29,"props":290,"children":291},{},[292,294,309],{"type":23,"value":293},"If you are using Laravel, ",{"type":17,"tag":67,"props":295,"children":298},{"href":296,"rel":297},"https://laravel.com/docs/11.x/deployment#the-health-route",[71],[299,301,307],{"type":23,"value":300},"modern versions of Laravel will ship with a ",{"type":17,"tag":58,"props":302,"children":304},{"className":303},[],[305],{"type":23,"value":306},"/up",{"type":23,"value":308}," route",{"type":23,"value":310}," that you can use to validate that Laravel is running and healthy.",{"type":17,"tag":29,"props":312,"children":313},{},[314],{"type":23,"value":315},"You can even create your own custom path in your application if you want. As long as the path returns a 200 status code, the health check will be successful.",{"type":17,"tag":35,"props":317,"children":319},{"id":318},"advanced-laravel-services",[320],{"type":23,"value":321},"Advanced Laravel Services",{"type":17,"tag":29,"props":323,"children":324},{},[325],{"type":23,"value":326},"Since it is good practice to use the same Docker image for all our services, we also make additional health checks for Laravel's advanced services. If you're looking for rolling updates with zero downtime, it's very important to use these health checks.",{"type":17,"tag":328,"props":329,"children":331},"h3",{"id":330},"laravel-horizon",[332],{"type":23,"value":333},"Laravel Horizon",{"type":17,"tag":29,"props":335,"children":336},{},[337,339,345],{"type":23,"value":338},"We utilize the ",{"type":17,"tag":58,"props":340,"children":342},{"className":341},[],[343],{"type":23,"value":344},"artisan horizon:status",{"type":23,"value":346}," command to check the status of Laravel Horizon. This is a command native to Laravel Horizon and is used to determine if the Horizon process is running.",{"type":17,"tag":29,"props":348,"children":349},{},[350,352,357],{"type":23,"value":351},"To run this command automatically, you can call our health check command in your ",{"type":17,"tag":58,"props":353,"children":355},{"className":354},[],[356],{"type":23,"value":86},{"type":23,"value":358}," file.",{"type":17,"tag":360,"props":361,"children":363},"code-panel",{"label":362},"Using Healthcheck with Laravel Horizon",[364],{"type":17,"tag":365,"props":366,"children":370},"pre",{"className":367,"code":368,"language":369,"meta":7,"style":7},"language-yaml shiki shiki-themes github-dark github-dark monokai","healthcheck:\n  test: [\"CMD\", \"healthcheck-horizon\"]\n","yaml",[371],{"type":17,"tag":58,"props":372,"children":373},{"__ignoreMap":7},[374,392],{"type":17,"tag":375,"props":376,"children":379},"span",{"class":377,"line":378},"line",1,[380,386],{"type":17,"tag":375,"props":381,"children":383},{"style":382},"--shiki-default:#85E89D;--shiki-dark:#85E89D;--shiki-sepia:#F92672",[384],{"type":23,"value":385},"healthcheck",{"type":17,"tag":375,"props":387,"children":389},{"style":388},"--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8;--shiki-sepia:#F8F8F2",[390],{"type":23,"value":391},":\n",{"type":17,"tag":375,"props":393,"children":395},{"class":377,"line":394},2,[396,401,406,412,417,422],{"type":17,"tag":375,"props":397,"children":398},{"style":382},[399],{"type":23,"value":400},"  test",{"type":17,"tag":375,"props":402,"children":403},{"style":388},[404],{"type":23,"value":405},": [",{"type":17,"tag":375,"props":407,"children":409},{"style":408},"--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF;--shiki-sepia:#E6DB74",[410],{"type":23,"value":411},"\"CMD\"",{"type":17,"tag":375,"props":413,"children":414},{"style":388},[415],{"type":23,"value":416},", ",{"type":17,"tag":375,"props":418,"children":419},{"style":408},[420],{"type":23,"value":421},"\"healthcheck-horizon\"",{"type":17,"tag":375,"props":423,"children":424},{"style":388},[425],{"type":23,"value":426},"]\n",{"type":17,"tag":29,"props":428,"children":429},{},[430],{"type":17,"tag":67,"props":431,"children":433},{"href":432},"/docs/laravel/laravel-horizon",[434],{"type":23,"value":435},"See a full example of configuring Laravel Horizon →",{"type":17,"tag":328,"props":437,"children":439},{"id":438},"laravel-reverb",[440],{"type":23,"value":441},"Laravel Reverb",{"type":17,"tag":29,"props":443,"children":444},{},[445,447,453,455,461],{"type":23,"value":446},"We use ",{"type":17,"tag":58,"props":448,"children":450},{"className":449},[],[451],{"type":23,"value":452},"pgrep",{"type":23,"value":454}," to check if the ",{"type":17,"tag":58,"props":456,"children":458},{"className":457},[],[459],{"type":23,"value":460},"reverb:start",{"type":23,"value":462}," command is running. This ensures the Reverb process is running and ready to accept connections.",{"type":17,"tag":29,"props":464,"children":465},{},[466,467,472],{"type":23,"value":351},{"type":17,"tag":58,"props":468,"children":470},{"className":469},[],[471],{"type":23,"value":86},{"type":23,"value":358},{"type":17,"tag":360,"props":474,"children":476},{"label":475},"Using Healthcheck with Laravel Reverb",[477],{"type":17,"tag":365,"props":478,"children":480},{"className":367,"code":479,"language":369,"meta":7,"style":7},"healthcheck:\n  test: [\"CMD\", \"healthcheck-reverb\"]\n",[481],{"type":17,"tag":58,"props":482,"children":483},{"__ignoreMap":7},[484,495],{"type":17,"tag":375,"props":485,"children":486},{"class":377,"line":378},[487,491],{"type":17,"tag":375,"props":488,"children":489},{"style":382},[490],{"type":23,"value":385},{"type":17,"tag":375,"props":492,"children":493},{"style":388},[494],{"type":23,"value":391},{"type":17,"tag":375,"props":496,"children":497},{"class":377,"line":394},[498,502,506,510,514,519],{"type":17,"tag":375,"props":499,"children":500},{"style":382},[501],{"type":23,"value":400},{"type":17,"tag":375,"props":503,"children":504},{"style":388},[505],{"type":23,"value":405},{"type":17,"tag":375,"props":507,"children":508},{"style":408},[509],{"type":23,"value":411},{"type":17,"tag":375,"props":511,"children":512},{"style":388},[513],{"type":23,"value":416},{"type":17,"tag":375,"props":515,"children":516},{"style":408},[517],{"type":23,"value":518},"\"healthcheck-reverb\"",{"type":17,"tag":375,"props":520,"children":521},{"style":388},[522],{"type":23,"value":426},{"type":17,"tag":29,"props":524,"children":525},{},[526],{"type":17,"tag":67,"props":527,"children":529},{"href":528},"/docs/laravel/laravel-reverb",[530],{"type":23,"value":531},"See a full example of configuring Laravel Reverb →",{"type":17,"tag":328,"props":533,"children":535},{"id":534},"laravel-scheduler",[536],{"type":23,"value":537},"Laravel Scheduler",{"type":17,"tag":29,"props":539,"children":540},{},[541,542,547,548,554],{"type":23,"value":446},{"type":17,"tag":58,"props":543,"children":545},{"className":544},[],[546],{"type":23,"value":452},{"type":23,"value":454},{"type":17,"tag":58,"props":549,"children":551},{"className":550},[],[552],{"type":23,"value":553},"schedule:work",{"type":23,"value":555}," command is running. This ensures the scheduler process is running.",{"type":17,"tag":29,"props":557,"children":558},{},[559,560,565],{"type":23,"value":351},{"type":17,"tag":58,"props":561,"children":563},{"className":562},[],[564],{"type":23,"value":86},{"type":23,"value":358},{"type":17,"tag":360,"props":567,"children":569},{"label":568},"Using Healthcheck with Laravel Scheduler",[570],{"type":17,"tag":365,"props":571,"children":573},{"className":367,"code":572,"language":369,"meta":7,"style":7},"healthcheck:\n  test: [\"CMD\", \"healthcheck-scheduler\"]\n",[574],{"type":17,"tag":58,"props":575,"children":576},{"__ignoreMap":7},[577,588],{"type":17,"tag":375,"props":578,"children":579},{"class":377,"line":378},[580,584],{"type":17,"tag":375,"props":581,"children":582},{"style":382},[583],{"type":23,"value":385},{"type":17,"tag":375,"props":585,"children":586},{"style":388},[587],{"type":23,"value":391},{"type":17,"tag":375,"props":589,"children":590},{"class":377,"line":394},[591,595,599,603,607,612],{"type":17,"tag":375,"props":592,"children":593},{"style":382},[594],{"type":23,"value":400},{"type":17,"tag":375,"props":596,"children":597},{"style":388},[598],{"type":23,"value":405},{"type":17,"tag":375,"props":600,"children":601},{"style":408},[602],{"type":23,"value":411},{"type":17,"tag":375,"props":604,"children":605},{"style":388},[606],{"type":23,"value":416},{"type":17,"tag":375,"props":608,"children":609},{"style":408},[610],{"type":23,"value":611},"\"healthcheck-scheduler\"",{"type":17,"tag":375,"props":613,"children":614},{"style":388},[615],{"type":23,"value":426},{"type":17,"tag":29,"props":617,"children":618},{},[619],{"type":17,"tag":67,"props":620,"children":622},{"href":621},"/docs/laravel/laravel-task-scheduler",[623],{"type":23,"value":624},"See a full example of configuring Laravel Scheduler →",{"type":17,"tag":328,"props":626,"children":628},{"id":627},"laravel-queue",[629],{"type":23,"value":630},"Laravel Queue",{"type":17,"tag":29,"props":632,"children":633},{},[634,635,640,641,647],{"type":23,"value":446},{"type":17,"tag":58,"props":636,"children":638},{"className":637},[],[639],{"type":23,"value":452},{"type":23,"value":454},{"type":17,"tag":58,"props":642,"children":644},{"className":643},[],[645],{"type":23,"value":646},"queue:work",{"type":23,"value":648}," command is running. This ensures the queue process is running.",{"type":17,"tag":29,"props":650,"children":651},{},[652,653,658],{"type":23,"value":351},{"type":17,"tag":58,"props":654,"children":656},{"className":655},[],[657],{"type":23,"value":86},{"type":23,"value":358},{"type":17,"tag":360,"props":660,"children":662},{"label":661},"Using Healthcheck with Laravel Queue",[663],{"type":17,"tag":365,"props":664,"children":666},{"className":367,"code":665,"language":369,"meta":7,"style":7},"healthcheck:\n  test: [\"CMD\", \"healthcheck-queue\"]\n",[667],{"type":17,"tag":58,"props":668,"children":669},{"__ignoreMap":7},[670,681],{"type":17,"tag":375,"props":671,"children":672},{"class":377,"line":378},[673,677],{"type":17,"tag":375,"props":674,"children":675},{"style":382},[676],{"type":23,"value":385},{"type":17,"tag":375,"props":678,"children":679},{"style":388},[680],{"type":23,"value":391},{"type":17,"tag":375,"props":682,"children":683},{"class":377,"line":394},[684,688,692,696,700,705],{"type":17,"tag":375,"props":685,"children":686},{"style":382},[687],{"type":23,"value":400},{"type":17,"tag":375,"props":689,"children":690},{"style":388},[691],{"type":23,"value":405},{"type":17,"tag":375,"props":693,"children":694},{"style":408},[695],{"type":23,"value":411},{"type":17,"tag":375,"props":697,"children":698},{"style":388},[699],{"type":23,"value":416},{"type":17,"tag":375,"props":701,"children":702},{"style":408},[703],{"type":23,"value":704},"\"healthcheck-queue\"",{"type":17,"tag":375,"props":706,"children":707},{"style":388},[708],{"type":23,"value":426},{"type":17,"tag":29,"props":710,"children":711},{},[712],{"type":17,"tag":67,"props":713,"children":715},{"href":714},"/docs/laravel/laravel-queue",[716],{"type":23,"value":717},"See a full example of configuring Laravel Queue →",{"type":17,"tag":719,"props":720,"children":721},"style",{},[722],{"type":23,"value":723},"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 .sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}html.sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}",{"title":7,"searchDepth":394,"depth":394,"links":725},[726,727,728,729,730],{"id":37,"depth":394,"text":40},{"id":48,"depth":394,"text":51},{"id":91,"depth":394,"text":94},{"id":247,"depth":394,"text":250},{"id":318,"depth":394,"text":321,"children":731},[732,734,735,736],{"id":330,"depth":733,"text":333},3,{"id":438,"depth":733,"text":441},{"id":534,"depth":733,"text":537},{"id":627,"depth":733,"text":630},"markdown","content:docs:3.guide:3.using-healthchecks-with-laravel.md","content","docs/3.guide/3.using-healthchecks-with-laravel.md","md",1727889281220]