CINXE.COM

Creating Persistent Workers  |  Bazel

<!doctype html> <html lang="en" dir="ltr"> <head> <meta name="google-signin-client-id" content="157101835696-ooapojlodmuabs2do2vuhhnf90bccmoi.apps.googleusercontent.com"> <meta name="google-signin-scope" content="profile email https://www.googleapis.com/auth/developerprofiles https://www.googleapis.com/auth/developerprofiles.award"> <meta property="og:site_name" content="Bazel"> <meta property="og:type" content="website"><meta name="theme-color" content="#0c713a"><meta charset="utf-8"> <meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="manifest" href="/_pwa/bazel/manifest.json" crossorigin="use-credentials"> <link rel="preconnect" href="//www.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.googleapis.com" crossorigin> <link rel="preconnect" href="//apis.google.com" crossorigin> <link rel="preconnect" href="//www.google-analytics.com" crossorigin><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap"> <link rel="stylesheet" href="//fonts.googleapis.com/css2?family=Material+Icons&family=Material+Symbols+Outlined&display=block"><link rel="stylesheet" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/css/app.css"> <link rel="shortcut icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/favicon-prod.png"> <link rel="apple-touch-icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/touchicon-180.png"><link rel="canonical" href="https://bazel.build/remote/creating"><link rel="search" type="application/opensearchdescription+xml" title="Bazel" href="https://bazel.build/s/opensearch.xml"> <link rel="alternate" hreflang="en" href="https://bazel.build/remote/creating" /><link rel="alternate" hreflang="x-default" href="https://bazel.build/remote/creating" /><link rel="alternate" hreflang="ar" href="https://bazel.build/remote/creating?hl=ar" /><link rel="alternate" hreflang="bn" href="https://bazel.build/remote/creating?hl=bn" /><link rel="alternate" hreflang="zh-Hans" href="https://bazel.build/remote/creating?hl=zh-cn" /><link rel="alternate" hreflang="zh-Hant" href="https://bazel.build/remote/creating?hl=zh-tw" /><link rel="alternate" hreflang="fa" href="https://bazel.build/remote/creating?hl=fa" /><link rel="alternate" hreflang="he" href="https://bazel.build/remote/creating?hl=he" /><link rel="alternate" hreflang="hi" href="https://bazel.build/remote/creating?hl=hi" /><link rel="alternate" hreflang="id" href="https://bazel.build/remote/creating?hl=id" /><link rel="alternate" hreflang="ja" href="https://bazel.build/remote/creating?hl=ja" /><link rel="alternate" hreflang="ko" href="https://bazel.build/remote/creating?hl=ko" /><link rel="alternate" hreflang="pt-BR" href="https://bazel.build/remote/creating?hl=pt-br" /><link rel="alternate" hreflang="es-419" href="https://bazel.build/remote/creating?hl=es-419" /><link rel="alternate" hreflang="th" href="https://bazel.build/remote/creating?hl=th" /><link rel="alternate" hreflang="tr" href="https://bazel.build/remote/creating?hl=tr" /><link rel="alternate" hreflang="vi" href="https://bazel.build/remote/creating?hl=vi" /><link rel="alternate" hreflang="en-cn" href="https://bazel.google.cn/remote/creating" /><link rel="alternate" hreflang="x-default" href="https://bazel.google.cn/remote/creating" /><link rel="alternate" hreflang="ar-cn" href="https://bazel.google.cn/remote/creating?hl=ar" /><link rel="alternate" hreflang="bn-cn" href="https://bazel.google.cn/remote/creating?hl=bn" /><link rel="alternate" hreflang="zh-Hans-cn" href="https://bazel.google.cn/remote/creating?hl=zh-cn" /><link rel="alternate" hreflang="zh-Hant-cn" href="https://bazel.google.cn/remote/creating?hl=zh-tw" /><link rel="alternate" hreflang="fa-cn" href="https://bazel.google.cn/remote/creating?hl=fa" /><link rel="alternate" hreflang="he-cn" href="https://bazel.google.cn/remote/creating?hl=he" /><link rel="alternate" hreflang="hi-cn" href="https://bazel.google.cn/remote/creating?hl=hi" /><link rel="alternate" hreflang="id-cn" href="https://bazel.google.cn/remote/creating?hl=id" /><link rel="alternate" hreflang="ja-cn" href="https://bazel.google.cn/remote/creating?hl=ja" /><link rel="alternate" hreflang="ko-cn" href="https://bazel.google.cn/remote/creating?hl=ko" /><link rel="alternate" hreflang="pt-BR-cn" href="https://bazel.google.cn/remote/creating?hl=pt-br" /><link rel="alternate" hreflang="es-419-cn" href="https://bazel.google.cn/remote/creating?hl=es-419" /><link rel="alternate" hreflang="th-cn" href="https://bazel.google.cn/remote/creating?hl=th" /><link rel="alternate" hreflang="tr-cn" href="https://bazel.google.cn/remote/creating?hl=tr" /><link rel="alternate" hreflang="vi-cn" href="https://bazel.google.cn/remote/creating?hl=vi" /><title>Creating Persistent Workers &nbsp;|&nbsp; Bazel</title> <meta property="og:title" content="Creating Persistent Workers &nbsp;|&nbsp; Bazel"><meta property="og:url" content="https://bazel.build/remote/creating"><meta property="og:locale" content="en"><script type="application/ld+json"> { "@context": "https://schema.org", "@type": "Article", "headline": "Creating Persistent Workers" } </script> <link rel="stylesheet" href="/extras.css"></head> <body class="" template="page" theme="bazel-theme" type="article" layout="docs" display-toc pending> <devsite-progress type="indeterminate" id="app-progress"></devsite-progress> <section class="devsite-wrapper"> <devsite-cookie-notification-bar></devsite-cookie-notification-bar><devsite-header role="banner"> <div class="devsite-header--inner nocontent"> <div class="devsite-top-logo-row-wrapper-wrapper"> <div class="devsite-top-logo-row-wrapper"> <div class="devsite-top-logo-row"> <button type="button" id="devsite-hamburger-menu" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Navigation menu button" visually-hidden aria-label="Open menu"> </button> <div class="devsite-product-name-wrapper"> <a href="/" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="bazel" track-metadata-position="nav" track-metadata-eventDetail="nav"> <picture> <img src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/lockup.svg" class="devsite-site-logo" alt="Bazel"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item "> </li> </ul> </span> </div> <div class="devsite-top-logo-row-middle"> <div class="devsite-header-upper-tabs"> <devsite-tabs class="upper-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Upper tabs"> <tab > <a href="https://bazel.build/about" track-metadata-eventdetail="https://bazel.build/about" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - about bazel" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: About Bazel" track-name="about bazel" > About Bazel </a> </tab> <tab > <a href="https://bazel.build/start" track-metadata-eventdetail="https://bazel.build/start" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - getting started" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Getting started" track-name="getting started" > Getting started </a> </tab> <tab class="devsite-active"> <a href="https://bazel.build/docs" track-metadata-eventdetail="https://bazel.build/docs" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - user guide" track-metadata-module="primary nav" aria-label="User guide, selected" data-category="Site-Wide Custom Events" data-label="Tab: User guide" track-name="user guide" > User guide </a> </tab> <tab > <a href="https://bazel.build/reference" track-metadata-eventdetail="https://bazel.build/reference" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - reference" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Reference" track-name="reference" > Reference </a> </tab> <tab > <a href="https://bazel.build/extending" track-metadata-eventdetail="https://bazel.build/extending" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - extending" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Extending" track-name="extending" > Extending </a> </tab> <tab > <a href="https://bazel.build/community" track-metadata-eventdetail="https://bazel.build/community" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - community" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" > Community </a> </tab> <tab class="devsite-dropdown "> <a href="https://bazel.build/versions" track-metadata-eventdetail="https://bazel.build/versions" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - versioned docs" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Versioned docs" track-name="versioned docs" > Versioned docs </a> <a href="#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Versioned docs" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions" track-metadata-position="nav - versioned docs" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Versioned docs" track-name="versioned docs" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/7.4.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/7.4.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 7.4 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/7.3.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/7.3.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 7.3 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/7.2.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/7.2.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 7.2 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/7.1.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/7.1.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 7.1 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/7.0.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/7.0.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 7.0 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/6.5.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/6.5.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 6.5 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://docs.bazel.build/versions/5.4.1/bazel-overview.html" track-type="nav" track-metadata-eventdetail="https://docs.bazel.build/versions/5.4.1/bazel-overview.html" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 5.4.1 </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"> <a href="https://bazel.build/" track-type="nav" track-metadata-eventdetail="https://bazel.build/" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> Nightly </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> More… </div> </a> </li> </ul> </div> </div> </div> </tab> </nav> </devsite-tabs> </div> <devsite-search enable-signin enable-search enable-suggestions enable-query-completion project-name="Bazel" tenant-name="Bazel" > <form class="devsite-search-form" action="https://bazel.build/s/results" method="GET"> <div class="devsite-search-container"> <button type="button" search-open class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Open search"></button> <div class="devsite-searchbox"> <input aria-activedescendant="" aria-autocomplete="list" aria-label="Search" aria-expanded="false" aria-haspopup="listbox" autocomplete="off" class="devsite-search-field devsite-search-query" name="q" placeholder="Search" role="combobox" type="text" value="" > <div class="devsite-search-image material-icons" aria-hidden="true"> </div> <div class="devsite-search-shortcut-icon-container" aria-hidden="true"> <kbd class="devsite-search-shortcut-icon">/</kbd> </div> </div> </div> </form> <button type="button" search-close class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Close search"></button> </devsite-search> </div> <devsite-language-selector> <ul role="presentation"> <li role="presentation"> <a role="menuitem" lang="en" >English</a> </li> <li role="presentation"> <a role="menuitem" lang="es_419" >Español – América Latina</a> </li> <li role="presentation"> <a role="menuitem" lang="id" >Indonesia</a> </li> <li role="presentation"> <a role="menuitem" lang="pt_br" >Português – Brasil</a> </li> <li role="presentation"> <a role="menuitem" lang="vi" >Tiếng Việt</a> </li> <li role="presentation"> <a role="menuitem" lang="tr" >Türkçe</a> </li> <li role="presentation"> <a role="menuitem" lang="he" >עברית</a> </li> <li role="presentation"> <a role="menuitem" lang="ar" >العربيّة</a> </li> <li role="presentation"> <a role="menuitem" lang="fa" >فارسی</a> </li> <li role="presentation"> <a role="menuitem" lang="hi" >हिंदी</a> </li> <li role="presentation"> <a role="menuitem" lang="bn" >বাংলা</a> </li> <li role="presentation"> <a role="menuitem" lang="th" >ภาษาไทย</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_cn" >中文 – 简体</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_tw" >中文 – 繁體</a> </li> <li role="presentation"> <a role="menuitem" lang="ja" >日本語</a> </li> <li role="presentation"> <a role="menuitem" lang="ko" >한국어</a> </li> </ul> </devsite-language-selector> <a class="devsite-header-link devsite-top-button button gc-analytics-event" href="//github.com/bazelbuild/bazel/" data-category="Site-Wide Custom Events" data-label="Site header link" > GitHub </a> <devsite-user enable-profiles id="devsite-user"> <span class="button devsite-top-button" aria-hidden="true" visually-hidden>Sign in</span> </devsite-user> </div> </div> </div> <div class="devsite-collapsible-section "> <div class="devsite-header-background"> <div class="devsite-product-id-row" > <div class="devsite-product-description-row"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item "> <a href="https://bazel.build/docs" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Lower Header" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="" > Guides and tutorials for learning to use Bazel </a> </li> </ul> </div> </div> <div class="devsite-doc-set-nav-row"> <devsite-tabs class="lower-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Lower tabs"> <tab > <a href="https://bazel.build/release" track-metadata-eventdetail="https://bazel.build/release" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - releases" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Releases" track-name="releases" > Releases </a> </tab> <tab > <a href="https://bazel.build/build/style-guide" track-metadata-eventdetail="https://bazel.build/build/style-guide" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - basics" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Basics" track-name="basics" > Basics </a> </tab> <tab > <a href="https://bazel.build/configure/attributes" track-metadata-eventdetail="https://bazel.build/configure/attributes" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - advanced" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Advanced" track-name="advanced" > Advanced </a> </tab> <tab class="devsite-active"> <a href="https://bazel.build/remote/rbe" track-metadata-eventdetail="https://bazel.build/remote/rbe" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - remote execution" track-metadata-module="primary nav" aria-label="Remote execution, selected" data-category="Site-Wide Custom Events" data-label="Tab: Remote execution" track-name="remote execution" > Remote execution </a> </tab> <tab > <a href="https://bazel.build/tutorials/cpp-use-cases" track-metadata-eventdetail="https://bazel.build/tutorials/cpp-use-cases" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - tutorials" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Tutorials" track-name="tutorials" > Tutorials </a> </tab> <tab > <a href="https://bazel.build/migrate" track-metadata-eventdetail="https://bazel.build/migrate" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - migrate" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Migrate" track-name="migrate" > Migrate </a> </tab> </nav> </devsite-tabs> </div> </div> </div> </div> </devsite-header> <devsite-book-nav scrollbars > <div class="devsite-book-nav-filter" > <span class="filter-list-icon material-icons" aria-hidden="true"></span> <input type="text" placeholder="Filter" aria-label="Type to filter" role="searchbox"> <span class="filter-clear-button hidden" data-title="Clear filter" aria-label="Clear filter" role="button" tabindex="0"></span> </div> <nav class="devsite-book-nav devsite-nav nocontent" aria-label="Side menu"> <div class="devsite-mobile-header"> <button type="button" id="devsite-close-nav" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Close navigation" aria-label="Close navigation"> </button> <div class="devsite-product-name-wrapper"> <a href="/" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="bazel" track-metadata-position="nav" track-metadata-eventDetail="nav"> <picture> <img src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/lockup.svg" class="devsite-site-logo" alt="Bazel"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item "> </li> </ul> </span> </div> </div> <div class="devsite-book-nav-wrapper"> <div class="devsite-mobile-nav-top"> <ul class="devsite-nav-list"> <li class="devsite-nav-item"> <a href="/about" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: About Bazel" track-name="about bazel" data-category="Site-Wide Custom Events" data-label="Responsive Tab: About Bazel" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > About Bazel </span> </a> </li> <li class="devsite-nav-item"> <a href="/start" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Getting started" track-name="getting started" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Getting started" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Getting started </span> </a> </li> <li class="devsite-nav-item"> <a href="/docs" class="devsite-nav-title gc-analytics-event devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: User guide" track-name="user guide" data-category="Site-Wide Custom Events" data-label="Responsive Tab: User guide" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > User guide </span> </a> <ul class="devsite-nav-responsive-tabs"> <li class="devsite-nav-item"> <a href="/release" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Releases" track-name="releases" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Releases" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Releases </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> <li class="devsite-nav-item"> <a href="/build/style-guide" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Basics" track-name="basics" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Basics" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Basics </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> <li class="devsite-nav-item"> <a href="/configure/attributes" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Advanced" track-name="advanced" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Advanced" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Advanced </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> <li class="devsite-nav-item"> <a href="/remote/rbe" class="devsite-nav-title gc-analytics-event devsite-nav-has-children devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: Remote execution" track-name="remote execution" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Remote execution" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip menu="_book"> Remote execution </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="_book"> </span> </a> </li> <li class="devsite-nav-item"> <a href="/tutorials/cpp-use-cases" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Tutorials" track-name="tutorials" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Tutorials" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Tutorials </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> <li class="devsite-nav-item"> <a href="/migrate" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Migrate" track-name="migrate" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Migrate" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Migrate </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> </ul> </li> <li class="devsite-nav-item"> <a href="/reference" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Reference" track-name="reference" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Reference" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Reference </span> </a> </li> <li class="devsite-nav-item"> <a href="/extending" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Extending" track-name="extending" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Extending" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Extending </span> </a> </li> <li class="devsite-nav-item"> <a href="/community" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Community" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Community </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Versioned docs" track-name="versioned docs" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Versioned docs" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Versioned docs </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"> <span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Versioned docs" track-name="versioned docs" > <span class="devsite-nav-text" tooltip menu="Versioned docs"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Versioned docs"> </span> </span> </li> </ul> </li> <li class="devsite-nav-item"> <a href="//github.com/bazelbuild/bazel/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: GitHub" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > GitHub </span> </a> </li> </ul> </div> <div class="devsite-mobile-nav-bottom"> <ul class="devsite-nav-list" menu="_book"> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Remote build execution (RBE)</span> </div></li> <li class="devsite-nav-item"><a href="/remote/rbe" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/rbe" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/rbe" ><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="/remote/rules" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/rules" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/rules" ><span class="devsite-nav-text" tooltip>RBE rules</span></a></li> <li class="devsite-nav-item"><a href="/remote/ci" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/ci" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/ci" ><span class="devsite-nav-text" tooltip>RBE CI</span></a></li> <li class="devsite-nav-item"><a href="/remote/dynamic" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/dynamic" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/dynamic" ><span class="devsite-nav-text" tooltip>Dynamic execution</span></a></li> <li class="devsite-nav-item"><a href="/remote/caching" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/caching" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/caching" ><span class="devsite-nav-text" tooltip>Remote caching</span></a></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Troubleshooting</span> </div></li> <li class="devsite-nav-item"><a href="/remote/sandbox" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/sandbox" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/sandbox" ><span class="devsite-nav-text" tooltip>Docker Sandbox</span></a></li> <li class="devsite-nav-item"><a href="/remote/workspace" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/workspace" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/workspace" ><span class="devsite-nav-text" tooltip>Non-hermetic WORKSPACE rules</span></a></li> <li class="devsite-nav-item"><a href="/remote/cache-remote" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/cache-remote" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/cache-remote" ><span class="devsite-nav-text" tooltip>Remote cache hits</span></a></li> <li class="devsite-nav-item"><a href="/remote/cache-local" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/cache-local" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/cache-local" ><span class="devsite-nav-text" tooltip>Local cache hits</span></a></li> <li class="devsite-nav-item"><a href="/remote/output-directories" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/output-directories" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/output-directories" ><span class="devsite-nav-text" tooltip>Output directory layout</span></a></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Persistent workers</span> </div></li> <li class="devsite-nav-item"><a href="/remote/persistent" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/persistent" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/persistent" ><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="/remote/multiplex" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/multiplex" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/multiplex" ><span class="devsite-nav-text" tooltip>Multiplex workers</span></a></li> <li class="devsite-nav-item"><a href="/remote/creating" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/creating" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/creating" ><span class="devsite-nav-text" tooltip>Creating workers</span></a></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Build Event Protocol</span> </div></li> <li class="devsite-nav-item"><a href="/remote/bep" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/bep" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/bep" ><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="/remote/bep-examples" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/bep-examples" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/bep-examples" ><span class="devsite-nav-text" tooltip>BEP examples</span></a></li> <li class="devsite-nav-item"><a href="/remote/bep-glossary" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /remote/bep-glossary" track-type="bookNav" track-name="click" track-metadata-eventdetail="/remote/bep-glossary" ><span class="devsite-nav-text" tooltip>BEP glossary</span></a></li> </ul> <ul class="devsite-nav-list" menu="Versioned docs" aria-label="Side menu" hidden> <li class="devsite-nav-item"> <a href="/versions/7.4.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 7.4" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 7.4 </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/7.3.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 7.3" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 7.3 </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/7.2.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 7.2" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 7.2 </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/7.1.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 7.1" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 7.1 </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/7.0.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 7.0" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 7.0 </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/6.5.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 6.5" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 6.5 </span> </a> </li> <li class="devsite-nav-item"> <a href="https://docs.bazel.build/versions/5.4.1/bazel-overview.html" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 5.4.1" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 5.4.1 </span> </a> </li> <li class="devsite-nav-item"> <a href="/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Nightly" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Nightly </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: More…" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > More… </span> </a> </li> </ul> </div> </div> </nav> </devsite-book-nav> <section id="gc-wrapper"> <main role="main" class="devsite-main-content" has-book-nav has-sidebar > <div class="devsite-sidebar"> <div class="devsite-sidebar-content"> <devsite-toc class="devsite-nav" role="navigation" aria-label="On this page" depth="2" scrollbars ></devsite-toc> <devsite-recommendations-sidebar class="nocontent devsite-nav"> </devsite-recommendations-sidebar> </div> </div> <devsite-content> <article class="devsite-article"> <div class="devsite-article-meta nocontent" role="navigation"> <ul class="devsite-breadcrumb-list" aria-label="Breadcrumb"> <li class="devsite-breadcrumb-item "> <a href="https://bazel.build/" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="Bazel" > Bazel </a> </li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div> <a href="https://bazel.build/docs" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="2" track-type="globalNav" track-name="breadcrumb" track-metadata-position="2" track-metadata-eventdetail="" > User guide </a> </li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div> <a href="https://bazel.build/remote/rbe" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="3" track-type="globalNav" track-name="breadcrumb" track-metadata-position="3" track-metadata-eventdetail="" > Remote execution </a> </li> </ul> <devsite-thumb-rating position="header"> </devsite-thumb-rating> </div> <devsite-feedback position="header" project-name="Bazel" product-id="5052038" bucket="https-bazel-build" context="" version="t-devsite-webserver-20241114-r00-rc02.464921008191574316" data-label="Send Feedback Button" track-type="feedback" track-name="sendFeedbackLink" track-metadata-position="header" class="nocontent" project-icon="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/touchicon-180.png" > <button> Send feedback </button> </devsite-feedback> <h1 class="devsite-page-title" tabindex="-1"> Creating Persistent Workers </h1> <devsite-feature-tooltip ack-key="AckCollectionsBookmarkTooltipDismiss" analytics-category="Site-Wide Custom Events" analytics-action-show="Callout Profile displayed" analytics-action-close="Callout Profile dismissed" analytics-label="Create Collection Callout" class="devsite-page-bookmark-tooltip nocontent" dismiss-button="true" id="devsite-collections-dropdown" dismiss-button-text="Dismiss" close-button-text="Got it"> <devsite-bookmark></devsite-bookmark> <span slot="popout-heading"> Stay organized with collections </span> <span slot="popout-contents"> Save and categorize content based on your preferences. </span> </devsite-feature-tooltip> <div class="devsite-page-title-meta"><devsite-view-release-notes></devsite-view-release-notes></div> <devsite-toc class="devsite-nav" depth="2" devsite-toc-embedded > </devsite-toc> <div class="devsite-article-body clearfix "> <a class="button button-with-icon" href="https://github.com/bazelbuild/bazel/issues/new?title=%5Bbazel.build%5D+Problem+with+/remote/creating&template=doc_issue.yml&link=https%3A%2F%2Fbazel.build/remote/creating" target="_blank"> Report an issue<span class="material-icons icon-after" aria-hidden="true" translate="no">open_in_new</span> </a> <a class="button button-with-icon" href="https://github.com/bazelbuild/bazel/tree/master/site/en/remote/creating.md" target="_blank"> View source<span class="material-icons icon-after" aria-hidden="true" translate="no">open_in_new</span> </a> <span style="float: right; line-height: 36px"> <strong>Nightly</strong> <!-- The lines below are updated by //scripts/docs:gen_new_toc --> <!-- BEGIN_VERSION_INDICATOR --> · <a href="/versions/7.4.0/remote/creating">7.4</a> . <a href="/versions/7.3.0/remote/creating">7.3</a> · <a href="/versions/7.2.0/remote/creating">7.2</a> · <a href="/versions/7.1.0/remote/creating">7.1</a> · <a href="/versions/7.0.0/remote/creating">7.0</a> · <a href="/versions/6.5.0/remote/creating">6.5</a> <!-- END_VERSION_INDICATOR --> </span> <p/> <p><a href="/remote/persistent">Persistent workers</a> can make your build faster. If you have repeated actions in your build that have a high startup cost or would benefit from cross-action caching, you may want to implement your own persistent worker to perform these actions.</p> <p>The Bazel server communicates with the worker using <code translate="no" dir="ltr">stdin</code>/<code translate="no" dir="ltr">stdout</code>. It supports the use of protocol buffers or JSON strings.</p> <p>The worker implementation has two parts:</p> <ul> <li>The <a href="#making-worker">worker</a>.</li> <li>The <a href="#rule-uses-worker">rule that uses the worker</a>.</li> </ul> <h2 id="making-worker" data-text="Making the worker" tabindex="-1">Making the worker</h2> <p>A persistent worker upholds a few requirements:</p> <ul> <li>It reads <a href="https://github.com/bazelbuild/bazel/blob/54a547f30fd582933889b961df1d6e37a3e33d85/src/main/protobuf/worker_protocol.proto#L36" class="external">WorkRequests</a> from its <code translate="no" dir="ltr">stdin</code>.</li> <li>It writes <a href="https://github.com/bazelbuild/bazel/blob/54a547f30fd582933889b961df1d6e37a3e33d85/src/main/protobuf/worker_protocol.proto#L77" class="external">WorkResponses</a> (and only <code translate="no" dir="ltr">WorkResponse</code>s) to its <code translate="no" dir="ltr">stdout</code>.</li> <li>It accepts the <code translate="no" dir="ltr">--persistent_worker</code> flag. The wrapper must recognize the <code translate="no" dir="ltr">--persistent_worker</code> command-line flag and only make itself persistent if that flag is passed, otherwise it must do a one-shot compilation and exit.</li> </ul> <p>If your program upholds these requirements, it can be used as a persistent worker!</p> <h3 id="work-requests" data-text="Work requests" tabindex="-1">Work requests</h3> <p>A <code translate="no" dir="ltr">WorkRequest</code> contains a list of arguments to the worker, a list of path-digest pairs representing the inputs the worker can access (this isn’t enforced, but you can use this info for caching), and a request id, which is 0 for singleplex workers.</p> <p>NOTE: While the protocol buffer specification uses &quot;snake case&quot; (<code translate="no" dir="ltr">request_id</code>), the JSON protocol uses &quot;camel case&quot; (<code translate="no" dir="ltr">requestId</code>). This document uses camel case in the JSON examples, but snake case when talking about the field regardless of protocol.</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="JSON"><code translate="no" dir="ltr"><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"arguments"</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-s2">"--some_argument"</span><span class="devsite-syntax-p">],</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"inputs"</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">[</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"path"</span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s2">"/path/to/my/file/1"</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"digest"</span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s2">"fdk3e2ml23d"</span><span class="devsite-syntax-p">},</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"path"</span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s2">"/path/to/my/file/2"</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"digest"</span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s2">"1fwqd4qdd"</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">],</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"requestId"</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-mi">12</span> <span class="devsite-syntax-p">}</span> </code></pre></devsite-code> <p>The optional <code translate="no" dir="ltr">verbosity</code> field can be used to request extra debugging output from the worker. It is entirely up to the worker what and how to output. Higher values indicate more verbose output. Passing the <code translate="no" dir="ltr">--worker_verbose</code> flag to Bazel sets the <code translate="no" dir="ltr">verbosity</code> field to 10, but smaller or larger values can be used manually for different amounts of output.</p> <p>The optional <code translate="no" dir="ltr">sandbox_dir</code> field is used only by workers that support <a href="/remote/multiplex">multiplex sandboxing</a>.</p> <h3 id="work-responses" data-text="Work responses" tabindex="-1">Work responses</h3> <p>A <code translate="no" dir="ltr">WorkResponse</code> contains a request id, a zero or nonzero exit code, and an output message describing any errors encountered in processing or executing the request. A worker should capture the <code translate="no" dir="ltr">stdout</code> and <code translate="no" dir="ltr">stderr</code> of any tool it calls and report them through the <code translate="no" dir="ltr">WorkResponse</code>. Writing it to the <code translate="no" dir="ltr">stdout</code> of the worker process is unsafe, as it will interfere with the worker protocol. Writing it to the <code translate="no" dir="ltr">stderr</code> of the worker process is safe, but the result is collected in a per-worker log file instead of ascribed to individual actions.</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="JSON"><code translate="no" dir="ltr"><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"exitCode"</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-mi">1</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"output"</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s2">"Action failed with the following message:\nCould not find input</span> <span class="devsite-syntax-s2"> file \"/path/to/my/file/1\""</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"requestId"</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-mi">12</span> <span class="devsite-syntax-p">}</span> </code></pre></devsite-code> <p>As per the norm for protobufs, all fields are optional. However, Bazel requires the <code translate="no" dir="ltr">WorkRequest</code> and the corresponding <code translate="no" dir="ltr">WorkResponse</code>, to have the same request id, so the request id must be specified if it is nonzero. This is a valid <code translate="no" dir="ltr">WorkResponse</code>.</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="JSON"><code translate="no" dir="ltr"><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-nt">"requestId"</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-mi">12</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-p">}</span> </code></pre></devsite-code> <p>A <code translate="no" dir="ltr">request_id</code> of 0 indicates a &quot;singleplex&quot; request, used when this request cannot be processed in parallel with other requests. The server guarantees that a given worker receives requests with either only <code translate="no" dir="ltr">request_id</code> 0 or only <code translate="no" dir="ltr">request_id</code> greater than zero. Singleplex requests are sent in serial, for example if the server doesn&#39;t send another request until it has received a response (except for cancel requests, see below).</p> <p><strong>Notes</strong></p> <ul> <li>Each protocol buffer is preceded by its length in <code translate="no" dir="ltr">varint</code> format (see <a href="https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/MessageLite.html#writeDelimitedTo-java.io.OutputStream-" class="external"><code translate="no" dir="ltr">MessageLite.writeDelimitedTo()</code></a>.</li> <li>JSON requests and responses are not preceded by a size indicator.</li> <li>JSON requests uphold the same structure as the protobuf, but use standard JSON and use camel case for all field names.</li> <li>In order to maintain the same backward and forward compatibility properties as protobuf, JSON workers must tolerate unknown fields in these messages, and use the protobuf defaults for missing values.</li> <li>Bazel stores requests as protobufs and converts them to JSON using <a href="https://cs.opensource.google/protobuf/protobuf/+/master:java/util/src/main/java/com/google/protobuf/util/JsonFormat.java">protobuf&#39;s JSON format</a></li> </ul> <h3 id="cancellation" data-text="Cancellation" tabindex="-1">Cancellation</h3> <p>Workers can optionally allow work requests to be cancelled before they finish. This is particularly useful in connection with dynamic execution, where local execution can regularly be interrupted by a faster remote execution. To allow cancellation, add <code translate="no" dir="ltr">supports-worker-cancellation: 1</code> to the <code translate="no" dir="ltr">execution-requirements</code> field (see below) and set the <code translate="no" dir="ltr">--experimental_worker_cancellation</code> flag.</p> <p>A <strong>cancel request</strong> is a <code translate="no" dir="ltr">WorkRequest</code> with the <code translate="no" dir="ltr">cancel</code> field set (and similarly a <strong>cancel response</strong> is a <code translate="no" dir="ltr">WorkResponse</code> with the <code translate="no" dir="ltr">was_cancelled</code> field set). The only other field that must be in a cancel request or cancel response is <code translate="no" dir="ltr">request_id</code>, indicating which request to cancel. The <code translate="no" dir="ltr">request_id</code> field will be 0 for singleplex workers or the non-0 <code translate="no" dir="ltr">request_id</code> of a previously sent <code translate="no" dir="ltr">WorkRequest</code> for multiplex workers. The server may send cancel requests for requests that the worker has already responded to, in which case the cancel request must be ignored.</p> <p>Each non-cancel <code translate="no" dir="ltr">WorkRequest</code> message must be answered exactly once, whether or not it was cancelled. Once the server has sent a cancel request, the worker may respond with a <code translate="no" dir="ltr">WorkResponse</code> with the <code translate="no" dir="ltr">request_id</code> set and the <code translate="no" dir="ltr">was_cancelled</code> field set to true. Sending a regular <code translate="no" dir="ltr">WorkResponse</code> is also accepted, but the <code translate="no" dir="ltr">output</code> and <code translate="no" dir="ltr">exit_code</code> fields will be ignored.</p> <p>Once a response has been sent for a <code translate="no" dir="ltr">WorkRequest</code>, the worker must not touch the files in its working directory. The server is free to clean up the files, including temporary files.</p> <h2 id="rule-uses-worker" data-text="Making the rule that uses the worker" tabindex="-1">Making the rule that uses the worker</h2> <p>You&#39;ll also need to create a rule that generates actions to be performed by the worker. Making a Starlark rule that uses a worker is just like <a href="https://github.com/bazelbuild/examples/tree/master/rules" class="external">creating any other rule</a>.</p> <p>In addition, the rule needs to contain a reference to the worker itself, and there are some requirements for the actions it produces.</p> <h3 id="referring_to_the_worker" data-text="Referring to the worker" tabindex="-1">Referring to the worker</h3> <p>The rule that uses the worker needs to contain a field that refers to the worker itself, so you&#39;ll need to create an instance of a <code translate="no" dir="ltr">\*\_binary</code> rule to define your worker. If your worker is called <code translate="no" dir="ltr">MyWorker.Java</code>, this might be the associated rule:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Python"><code translate="no" dir="ltr"><span class="devsite-syntax-n">java_binary</span><span class="devsite-syntax-p">(</span> <span class="devsite-syntax-n">name</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-s2">"worker"</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">srcs</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-p">[</span><span class="devsite-syntax-s2">"MyWorker.Java"</span><span class="devsite-syntax-p">],</span> <span class="devsite-syntax-p">)</span> </code></pre></devsite-code> <p>This creates the &quot;worker&quot; label, which refers to the worker binary. You&#39;ll then define a rule that <em>uses</em> the worker. This rule should define an attribute that refers to the worker binary.</p> <p>If the worker binary you built is in a package named &quot;work&quot;, which is at the top level of the build, this might be the attribute definition:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Python"><code translate="no" dir="ltr"><span class="devsite-syntax-s2">"worker"</span><span class="devsite-syntax-p">:</span> <span class="devsite-syntax-n">attr</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">label</span><span class="devsite-syntax-p">(</span> <span class="devsite-syntax-n">default</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">Label</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s2">"//work:worker"</span><span class="devsite-syntax-p">),</span> <span class="devsite-syntax-n">executable</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-kc">True</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">cfg</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-s2">"exec"</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-p">)</span> </code></pre></devsite-code> <p><code translate="no" dir="ltr">cfg = &quot;exec&quot;</code> indicates that the worker should be built to run on your execution platform rather than on the target platform (i.e., the worker is used as tool during the build).</p> <h3 id="work-action-requirements" data-text="Work action requirements" tabindex="-1">Work action requirements</h3> <p>The rule that uses the worker creates actions for the worker to perform. These actions have a couple of requirements.</p> <ul> <li><p>The <em>&quot;arguments&quot;</em> field. This takes a list of strings, all but the last of which are arguments passed to the worker upon startup. The last element in the &quot;arguments&quot; list is a <code translate="no" dir="ltr">flag-file</code> (@-preceded) argument. Workers read the arguments from the specified flagfile on a per-WorkRequest basis. Your rule can write non-startup arguments for the worker to this flagfile.</p></li> <li><p>The <em>&quot;execution-requirements&quot;</em> field, which takes a dictionary containing <code translate="no" dir="ltr">&quot;supports-workers&quot; : &quot;1&quot;</code>, <code translate="no" dir="ltr">&quot;supports-multiplex-workers&quot; : &quot;1&quot;</code>, or both.</p> <p>The &quot;arguments&quot; and &quot;execution-requirements&quot; fields are required for all actions sent to workers. Additionally, actions that should be executed by JSON workers need to include <code translate="no" dir="ltr">&quot;requires-worker-protocol&quot; : &quot;json&quot;</code> in the execution requirements field. <code translate="no" dir="ltr">&quot;requires-worker-protocol&quot; : &quot;proto&quot;</code> is also a valid execution requirement, though it’s not required for proto workers, since they are the default.</p> <p>You can also set a <code translate="no" dir="ltr">worker-key-mnemonic</code> in the execution requirements. This may be useful if you&#39;re reusing the executable for multiple action types and want to distinguish actions by this worker.</p></li> <li><p>Temporary files generated in the course of the action should be saved to the worker&#39;s directory. This enables sandboxing.</p></li> </ul> <aside class="note"><strong>Note:</strong><span> To pass an argument starting with a literal <code translate="no" dir="ltr">@</code>, start the argument with <code translate="no" dir="ltr">@@</code> instead. If an argument is also an external repository label, it will not be considered a flagfile argument.</span></aside> <p>Assuming a rule definition with &quot;worker&quot; attribute described above, in addition to a &quot;srcs&quot; attribute representing the inputs, an &quot;output&quot; attribute representing the outputs, and an &quot;args&quot; attribute representing the worker startup args, the call to <code translate="no" dir="ltr">ctx.actions.run</code> might be:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Python"><code translate="no" dir="ltr"><span class="devsite-syntax-n">ctx</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">actions</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">run</span><span class="devsite-syntax-p">(</span> <span class="devsite-syntax-n">inputs</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-n">ctx</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">files</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">srcs</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">outputs</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-n">ctx</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">outputs</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">output</span><span class="devsite-syntax-p">],</span> <span class="devsite-syntax-n">executable</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-n">ctx</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">executable</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">worker</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">mnemonic</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-s2">"someMnemonic"</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">execution_requirements</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-s2">"supports-workers"</span> <span class="devsite-syntax-p">:</span> <span class="devsite-syntax-s2">"1"</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-s2">"requires-worker-protocol"</span> <span class="devsite-syntax-p">:</span> <span class="devsite-syntax-s2">"json"</span><span class="devsite-syntax-p">},</span> <span class="devsite-syntax-n">arguments</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-n">ctx</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">attr</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">args</span> <span class="devsite-syntax-o">+</span> <span class="devsite-syntax-p">[</span><span class="devsite-syntax-s2">"@flagfile"</span><span class="devsite-syntax-p">]</span> <span class="devsite-syntax-p">)</span> </code></pre></devsite-code> <p>For another example, see <a href="/remote/persistent#implementation">Implementing persistent workers</a>.</p> <h2 id="examples" data-text="Examples" tabindex="-1">Examples</h2> <p>The Bazel code base uses <a href="https://github.com/bazelbuild/bazel/blob/a4251eab6988d6cf4f5e35681fbe2c1b0abe48ef/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/BazelJavaBuilder.java" class="external">Java compiler workers</a>, in addition to an <a href="https://github.com/bazelbuild/bazel/blob/c65f768fec9889bbf1ee934c61d0dc061ea54ca2/src/test/java/com/google/devtools/build/lib/worker/ExampleWorker.java" class="external">example JSON worker</a> that is used in our integration tests.</p> <p>You can use their <a href="https://github.com/bazelbuild/bazel/blob/a4251eab6988d6cf4f5e35681fbe2c1b0abe48ef/src/main/java/com/google/devtools/build/lib/worker/WorkRequestHandler.java" class="external">scaffolding</a> to make any Java-based tool into a worker by passing in the correct callback.</p> <p>For an example of a rule that uses a worker, take a look at Bazel&#39;s <a href="https://github.com/bazelbuild/bazel/blob/22b4dbcaf05756d506de346728db3846da56b775/src/test/shell/integration/bazel_worker_test.sh#L106" class="external">worker integration test</a>.</p> <p>External contributors have implemented workers in a variety of languages; take a look at <a href="https://github.com/Ubehebe/bazel-worker-examples" class="external">Polyglot implementations of Bazel persistent workers</a>. You can <a href="https://github.com/search?q=bazel+workrequest&amp;type=Code" class="external">find many more examples on GitHub</a>!</p> </div> <devsite-thumb-rating position="footer"> </devsite-thumb-rating> <devsite-feedback position="footer" project-name="Bazel" product-id="5052038" bucket="https-bazel-build" context="" version="t-devsite-webserver-20241114-r00-rc02.464921008191574316" data-label="Send Feedback Button" track-type="feedback" track-name="sendFeedbackLink" track-metadata-position="footer" class="nocontent" project-icon="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/touchicon-180.png" > <button> Send feedback </button> </devsite-feedback> <div class="devsite-floating-action-buttons"> </div> </article> <devsite-content-footer class="nocontent"> <p>Except as otherwise noted, the content of this page is licensed under the <a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 License</a>, and code samples are licensed under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0 License</a>. For details, see the <a href="https://developers.google.com/site-policies">Google Developers Site Policies</a>. Java is a registered trademark of Oracle and/or its affiliates.</p> <p>Last updated 2024-10-22 UTC.</p> </devsite-content-footer> <devsite-notification > </devsite-notification> <div class="devsite-content-data"> <template class="devsite-thumb-rating-feedback"> <devsite-feedback position="thumb-rating" project-name="Bazel" product-id="5052038" bucket="https-bazel-build" context="" version="t-devsite-webserver-20241114-r00-rc02.464921008191574316" data-label="Send Feedback Button" track-type="feedback" track-name="sendFeedbackLink" track-metadata-position="thumb-rating" class="nocontent" project-icon="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/touchicon-180.png" > <button> Need to tell us more? </button> </devsite-feedback> </template> <template class="devsite-content-data-template"> [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-22 UTC."],[],[]] </template> </div> </devsite-content> </main> <devsite-footer-promos class="devsite-footer"> </devsite-footer-promos> <devsite-footer-linkboxes class="devsite-footer"> <nav class="devsite-footer-linkboxes nocontent" aria-label="Footer links"> <ul class="devsite-footer-linkboxes-list"> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">About</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="/community/users" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Who's using Bazel </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/contribute/" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > Contribute </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/contribute/contribution-policy" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > Governance model </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/release" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > Release model </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/brand" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)" > Brand guidelines </a> </li> </ul> </li> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">Stay connected</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="//blog.bazel.build" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Blog </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//github.com/bazelbuild/bazel" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > GitHub </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//twitter.com/bazelbuild" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > Twitter </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//youtube.com/user/googleOSPO" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > YouTube </a> </li> </ul> </li> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">Support</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="/help" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Support </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//github.com/bazelbuild/bazel/issues" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > Issue tracker </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//slack.bazel.build" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > Slack </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//stackoverflow.com/questions/tagged/bazel" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > Stack Overflow </a> </li> </ul> </li> </ul> </nav> </devsite-footer-linkboxes> <devsite-footer-utility class="devsite-footer"> <div class="devsite-footer-utility nocontent"> <nav class="devsite-footer-utility-links" aria-label="Utility links"> <ul class="devsite-footer-utility-list"> <li class="devsite-footer-utility-item "> <a class="devsite-footer-utility-link gc-analytics-event" href="//policies.google.com/terms" data-category="Site-Wide Custom Events" data-label="Footer Terms link" > Terms </a> </li> <li class="devsite-footer-utility-item "> <a class="devsite-footer-utility-link gc-analytics-event" href="//policies.google.com/privacy" data-category="Site-Wide Custom Events" data-label="Footer Privacy link" > Privacy </a> </li> <li class="devsite-footer-utility-item glue-cookie-notification-bar-control"> <a class="devsite-footer-utility-link gc-analytics-event" href="#" data-category="Site-Wide Custom Events" data-label="Footer Manage cookies link" aria-hidden="true" > Manage cookies </a> </li> </ul> <devsite-language-selector> <ul role="presentation"> <li role="presentation"> <a role="menuitem" lang="en" >English</a> </li> <li role="presentation"> <a role="menuitem" lang="es_419" >Español – América Latina</a> </li> <li role="presentation"> <a role="menuitem" lang="id" >Indonesia</a> </li> <li role="presentation"> <a role="menuitem" lang="pt_br" >Português – Brasil</a> </li> <li role="presentation"> <a role="menuitem" lang="vi" >Tiếng Việt</a> </li> <li role="presentation"> <a role="menuitem" lang="tr" >Türkçe</a> </li> <li role="presentation"> <a role="menuitem" lang="he" >עברית</a> </li> <li role="presentation"> <a role="menuitem" lang="ar" >العربيّة</a> </li> <li role="presentation"> <a role="menuitem" lang="fa" >فارسی</a> </li> <li role="presentation"> <a role="menuitem" lang="hi" >हिंदी</a> </li> <li role="presentation"> <a role="menuitem" lang="bn" >বাংলা</a> </li> <li role="presentation"> <a role="menuitem" lang="th" >ภาษาไทย</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_cn" >中文 – 简体</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_tw" >中文 – 繁體</a> </li> <li role="presentation"> <a role="menuitem" lang="ja" >日本語</a> </li> <li role="presentation"> <a role="menuitem" lang="ko" >한국어</a> </li> </ul> </devsite-language-selector> </nav> </div> </devsite-footer-utility> <devsite-panel></devsite-panel> </section></section> <devsite-sitemask></devsite-sitemask> <devsite-snackbar></devsite-snackbar> <devsite-tooltip ></devsite-tooltip> <devsite-heading-link></devsite-heading-link> <devsite-analytics> <script type="application/json" analytics>[{&#34;dimensions&#34;: {&#34;dimension4&#34;: &#34;en&#34;, &#34;dimension2&#34;: false, &#34;dimension3&#34;: &#34;en&#34;, &#34;dimension1&#34;: &#34;Signed out&#34;, &#34;dimension5&#34;: false}, &#34;gaid&#34;: &#34;UA-61082125-3&#34;, &#34;metrics&#34;: {}, &#34;purpose&#34;: 0}]</script> <script type="application/json" tag-management>{&#34;at&#34;: &#34;True&#34;, &#34;ga4&#34;: [{&#34;id&#34;: &#34;G-GBZW986TQ3&#34;, &#34;purpose&#34;: 0}], &#34;ga4p&#34;: [{&#34;id&#34;: &#34;G-GBZW986TQ3&#34;, &#34;purpose&#34;: 0}], &#34;gtm&#34;: [], &#34;parameters&#34;: {&#34;internalUser&#34;: &#34;False&#34;, &#34;language&#34;: {&#34;machineTranslated&#34;: &#34;False&#34;, &#34;requested&#34;: &#34;en&#34;, &#34;served&#34;: &#34;en&#34;}, &#34;pageType&#34;: &#34;article&#34;, &#34;projectName&#34;: &#34;Bazel&#34;, &#34;signedIn&#34;: &#34;False&#34;, &#34;tenant&#34;: &#34;bazel&#34;, &#34;recommendations&#34;: {&#34;sourcePage&#34;: &#34;&#34;, &#34;sourceType&#34;: 0, &#34;sourceRank&#34;: 0, &#34;sourceIdenticalDescriptions&#34;: 0, &#34;sourceTitleWords&#34;: 0, &#34;sourceDescriptionWords&#34;: 0, &#34;experiment&#34;: &#34;&#34;}, &#34;experiment&#34;: {&#34;ids&#34;: &#34;&#34;}}}</script> </devsite-analytics> <devsite-badger></devsite-badger> <script nonce="FQLmjx/VqCmuarN0tUAGe7iHyf7IwF"> (function(d,e,v,s,i,t,E){d['GoogleDevelopersObject']=i; t=e.createElement(v);t.async=1;t.src=s;E=e.getElementsByTagName(v)[0]; E.parentNode.insertBefore(t,E);})(window, document, 'script', 'https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/js/app_loader.js', '[40,"en",null,"/js/devsite_app_module.js","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel","https://bazel-dot-devsite-v2-prod-3p.appspot.com",null,null,["/_pwa/bazel/manifest.json","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/images/video-placeholder.svg","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/favicon-prod.png","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/lockup.svg","https://fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap"],1,null,[1,6,8,12,14,17,21,25,50,52,63,70,75,76,80,87,91,92,93,97,98,100,101,102,103,104,105,107,108,109,110,112,113,116,117,118,120,122,124,125,126,127,129,130,131,132,133,134,135,136,138,140,141,147,148,149,151,152,156,157,158,159,161,163,164,168,169,170,179,180,182,183,186,191,193,196],"AIzaSyCNm9YxQumEXwGJgTDjxoxXK6m1F-9720Q","AIzaSyCc76DZePGtoyUjqKrLdsMGk_ry7sljLbY","bazel.build","AIzaSyB9bqgQ2t11WJsOX8qNsCQ6U-w91mmqF-I","AIzaSyAdYnStPdzjcJJtQ0mvIaeaMKj7_t6J_Fg",null,null,null,["TpcFeatures__enable_required_headers","Profiles__enable_release_notes_notifications","MiscFeatureFlags__enable_project_variables","Experiments__reqs_query_experiments","MiscFeatureFlags__enable_explain_this_code","Profiles__enable_recognition_badges","MiscFeatureFlags__enable_variable_operator","Profiles__enable_complete_playlist_endpoint","Search__enable_dynamic_content_confidential_banner","Profiles__enable_public_developer_profiles","TpcFeatures__enable_mirror_tenant_redirects","DevPro__enable_developer_subscriptions","Profiles__require_profile_eligibility_for_signin","Cloud__enable_cloud_facet_chat","Profiles__enable_completecodelab_endpoint","MiscFeatureFlags__developers_footer_image","MiscFeatureFlags__enable_firebase_utm","SignIn__enable_oauth_multi_account_support","Cloud__enable_cloud_shell_fte_user_flow","Profiles__enable_awarding_url","Profiles__enable_page_saving","Cloud__enable_cloudx_experiment_ids","Cloud__enable_legacy_calculator_redirect","MiscFeatureFlags__developers_footer_dark_image","Cloud__enable_llm_concierge_chat","Search__enable_ai_eligibility_checks","Cloud__enable_cloud_dlp_service","BookNav__enable_tenant_cache_key","MiscFeatureFlags__emergency_css","CloudShell__cloud_code_overflow_menu","OnSwitch__enable","Profiles__enable_dashboard_curated_recommendations","Search__enable_suggestions_from_borg","Cloud__enable_cloud_shell","DevPro__enable_cloud_innovators_plus","SignIn__enable_auto_login_multi_account","Cloud__enable_free_trial_server_call","Profiles__enable_profile_collections","SignIn__enable_refresh_access_tokens","CloudShell__cloud_shell_button","EngEduTelemetry__enable_engedu_telemetry","Profiles__enable_developer_profiles_callout","Search__enable_page_map","MiscFeatureFlags__enable_view_transitions","Cloud__enable_cloudx_ping","Analytics__enable_clearcut_logging","Concierge__enable_pushui"],null,null,"AIzaSyA58TaKli1DculwmAmbpzLVGuWc8eCQgQc","https://developerscontentserving-pa.googleapis.com","AIzaSyDWBU60w0P9hEkr29kkksYs8Z7gvZ8u_wc","https://developerscontentsearch-pa.googleapis.com",2,4,null,"https://developerprofiles-pa.googleapis.com",[40,"bazel","Bazel","bazel.build",null,"bazel-dot-devsite-v2-prod-3p.appspot.com",null,null,[null,1,null,null,null,null,null,null,null,null,null,[1],null,null,null,null,null,null,[1],null,null,null,null,[1,1,1],[1,1,null,1,1]],null,[56,null,null,null,null,null,"/images/lockup.svg",null,null,null,null,1,null,null,null,null,null,null,null,null,null,1,null,null,null,null,[]],[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[6,7,1,18,20,22,23,29,37,39,40,43],null,[[],[1,1]],[[["UA-61082125-3"],["UA-61082125-4"],null,null,["UA-61082125-5"],null,null,[["G-GBZW986TQ3"],null,null,[["G-GBZW986TQ3",1]]],[["UA-61082125-3",1]],null,[["UA-61082125-5",1]],null,1],[[1,1],[2,2],[4,5],[5,8],[3,4]]],null,4]]') </script> <devsite-a11y-announce></devsite-a11y-announce> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10